oracle sql语句里 我查询A表信息,其中要加入一虚拟列I, 判断A表外键在B表中是否存在信息,存在I列显示true,

2025-03-16 04:45:26
推荐回答(2个)
回答1:

select a.*,case when b.column is not null then 'ture' else 'false' end
from a left join b on a.column=b.column;

其中a.column=b.column就是连接关系

回答2:

select a.*,a.column,'true' from a,b where a.column=b.column
union all
select a.*,a.column,'false' from a where not exists(select b.column from b where a.column=b.column)