select t1.*
from table1 t1
where
exists (select 1 from table2 t2 where t2.id = t1.id)
or exists (select 1 from table3 t3 where t3.id = t1.id)
如果要显示来自其他表的数据,请使用 left join 而是:
select t1.id, t2.col1, t3.cola
from table1 t1
left join table2 t2 on t2.id = t1.id
left join table3 t3 on t3.id = t1.id
where coalesce(t2.id, t3.id) is not null
1条答案
按热度按时间eeq64g8w1#
你可以用
exists
:如果要显示来自其他表的数据,请使用
left join
而是: