子查询(IN表达式)
用于限制条件表达式
-- 查询字段为值1,值2,值3的数据
where 字段名 in(值1,值2,值3,...)
-- 查询字段不为值1,值2,值3的数据
where 字段名 not in(值1,值2,值3,...)
-- 通过子查询来限制主查询
select * from 表1
where 字段名 in (select 字段名 from 表2)
子查询(EXISTS)
exists 返回的是一个bool类型
select a.StudentNo, a.StudentName, a.Age, a.Sex from students as a
-- 返回false不显示 返回true显示
where exists(select * from student_lesson b where a.StudentNo = b.StudentNo)