父查询exists(子查询), exists()如果子查询有数据则返回ture,就是满足触发条件了,可以执行父查询了。
如果括号内子查询没有返回记录,说明不存在,不满足触发条件,就返回false,父查询不执行。
这个函数 就是检验子查询是否有记录,有则ture,无责false,ture就执行父查询,false就不执行。
select * from student where not exist (
select * from class where class.class_id = student.class_id
and class.class_name = '20120702030601'
)
表示查询不在班级20120702030601的学生