[Solved] SQL – add column to select and fiil it [closed]


select id, column_1, column_2,
case when id in (12,22,456,56) then 1 else 0 end as zzz
from tablename

The IN clause in the case statement can be replaced with a table name having those id’s like:

select id, column_1, column_2,
case when id in (select distinct id from table2) then 1 else 0 end as zzz
from tablename

solved SQL – add column to select and fiil it [closed]