您的位置:首页 > 数据库 > MySQL

43.笔记 MySQL学习——EXISTS 和 NOT EXISTS子查询

2017-11-17 21:24 381 查看
43.笔记 MySQL学习——EXISTS 和 NOT EXISTS子查询
运算符EXISTS和 NOT EXISTS只会测试某个子查询是否返回了行。如果有返回,EXISTS为真,而NOT EXISTS结果为假。

mysql> select exists (select * from absence);

+--------------------------------+

| exists (select * from absence) |

+--------------------------------+

|                              1 |

+--------------------------------+

1 row in set (0.00 sec)

mysql> select not exists (select * from absence);

+------------------------------------+

| not exists (select * from absence) |

+------------------------------------+

|                                  0 |

+------------------------------------+

1 row in set (0.00 sec)

在相关子查询中比较常见。

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 
 

 

 

 

 

 

 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: