lige-H

exists : 强调的是是否返回结果集,不要求知道返回什么, 比如:
  select name from student where sex = \'m\' and mark exists(select 1 from grade where ...) ,只要
exists引导的子句有结果集返回,那么exists这个条件就算成立了,大家注意返回的字段始终为1,如果改成“select 2 from grade where ...”,那么返回的字段就是2,这个数字没有意义。所以exists子句不在乎返回什么,而是在乎是不是有结果集返回。

而 exists 与 in 最大的区别在于 in引导的子句只能返回一个字段,比如:
  select name from student where sex = \'m\' and mark in (select 1,2,3 from grade where ...)  
,in子句返回了三个字段,这是不正确的,exists子句是允许的,但in只允许有一个字段返回,在1,2,3中随便去了两个字段即可。

分类:

技术点:

相关文章:

  • 2021-11-28
  • 2021-09-24
  • 2022-01-19
  • 2022-01-17
猜你喜欢
  • 2021-08-10
  • 2021-09-14
  • 2021-07-21
  • 2021-11-18
  • 2021-08-18
  • 2021-09-14
  • 2021-09-14
相关资源
相似解决方案