exists用法

2026-08-21

1、EXISTS在SQL中的作用是:检验查询是否返回数据。select a.* from tb a where exists(select 1 from tb where name =a.name)返回真假,当 where 后面的条件成立,则列出数据,否则为空。 2、exists强调的是是否返回结果集,不要求知道返回什么。比如:select name from student where sex = 'm' and mark exists(select 1 from grade where ....

阅读更多