Skip to content
Advertisement

Default values for each key in a where-clause

Given a table:

I need to set 0 for every ID in where-clause along with IDs:

Result

What query can I use here?

Upd1: let it be Postgres.

Upd2: can I do it without joins?

Advertisement

Answer

You didn’t mention your DBMS, but the following is standard ANSI SQL:

It’s possible without a join, but that doesn’t make it prettier:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement