高级查询2
exists 子查询;
1.用exists检测表是否已经创建
drop table if exists info
create table info(
#省略建表语句
)
2.select 字段名 from info where exists(子查询)
子查询有返回结果:exists子查询结果为true
子查询无返回结果:exists子查询结果为false,外层查询不执行
3.exists只对子查询进行结果判定,不影响最终结果
子查询注意事项:
1.子查询语句可以嵌套在SQL语句中任何表达式出现的位置
2.只出现在子查询中而没有出现在父查询中的表不能包含在输出列中
十五
最新推荐文章于 2024-05-13 10:45:34 发布