select t.*
from tab t
where not exists (select 1 from tab s where s.pid = t.cid)
from tab t
where not exists (select 1 from tab s where s.pid = t.cid)
SQL查询技巧
本文介绍了一种使用SQL进行复杂查询的方法,通过一个具体的例子展示了如何利用NOT EXISTS子查询来过滤目标记录,实现高效的数据检索。
1690
1457

被折叠的 条评论
为什么被折叠?