in的写法:
select product_id
from product
where product_id=17=67
and item_no in (select item_no from items)
exists的写法:
select a.product_id
from product a
where a.product_id=17=67
and exists (select 'x' from items b where b.item_no=a.item_no)
本文对比了SQL中in与exists两种子查询方式的使用方法。in子查询通过比较两个集合来筛选数据,而exists则检查子查询是否返回至少一行数据。文中提供了具体的SQL示例,帮助读者理解两者的不同之处。
in的写法:
select product_id
from product
where product_id=17=67
and item_no in (select item_no from items)
exists的写法:
select a.product_id
from product a
where a.product_id=17=67
and exists (select 'x' from items b where b.item_no=a.item_no)
1040

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