MySQL子查询(exists子查询)
1:Exists子查询就是用来判断某些条件是否知足(跨表),Exists是接在where以后,Exists返回的结果只有0和1
2:返回结果的演示
SELECT EXISTS(SELECT * FROM t_student);3:
SELECT EXISTS(SELECT * FROM t_student WHERE id=10);
3:案例演示
需求:查询全部的学生,前提条件是班级存在
1:肯定数据源
select * from t_student where ?;
2:肯定条件是否知足
Exists(select * from t_class);
3:SQL语句
1:SELECT * FROM t_student WHERE EXISTS(SELECT * FROM t_class);