找回密码
 免费注册

mysql数据库教程:exists子查询

[复制链接]
发表于 2022-11-28 14:58:36 | 显示全部楼层 |阅读模式
mysql数据库教程:exists子查询

  1. -- 如果笔试成绩有人超过80人,就显示所有学生信息
  2. mysql> select * from stuinfo where exists (select * from stumarks where writtenexam>=80);

  3. -- 没有超过80的学生,就显示所有学生信息
  4. mysql> select * from stuinfo where not exists (select * from stumarks where writtenexam>=80);
  5. Empty set (0.00 sec)
复制代码
作用:提高查询效率。

QQ|Archiver|小黑屋|网站地图|深圳市金黑网络技术有限公司 ( 粤ICP备2021124338号|粤公网安备 44030702003689号 )

GMT+8, 2026-8-8 15:03 , Processed in 0.044517 second(s), 22 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表