比如 a,b 關聯列為 a.id = b.id,現在要取 a 中的數據,其中id在b中也存在:
select * from a where exists(select 1 from b where b.id = a.id)
或者:
現在要取 a 中的數據,其中id在b中 不存在:
select * from a where not exists(select 1 from b where a.id = b.id)
比如 a,b 關聯列為 a.id = b.id,現在要取 a 中的數據,其中id在b中也存在:
select * from a where exists(select 1 from b where b.id = a.id)
或者:
現在要取 a 中的數據,其中id在b中 不存在:
select * from a where not exists(select 1 from b where a.id = b.id)
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。