exists貌似不是标准sql
exists()是用来判断括号里面的值或者结果集是否为null的,
如果select 1 from b where id=a.id这一句能查出来数据,那么查出来的a表中的数据是这样写是一样的
:select * from a where id in(select id from b);只不过在用in查询的时候要进行全表查询,效率没有exists高
select * from J_YHDA t
where exists (select null from dual) //oracle中这样写. 在子查询中使用 NULL
仍然返回结果集 等同select all .没where
别的数据库好像这样写也行
select * from J_YHDA t
select * from TableIn where exists(select BID from TableEx where
BNAME=TableIn.ANAME)
本文对比了SQL查询中IN与EXISTS关键字的使用场景及效率差异。阐述了IN适用于已知查询结果较少的情况,而EXISTS则更适合处理多个条件或预期返回大量数据的情况。同时介绍了这两种方法的基本语法及其在不同数据库系统中的应用。

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



