一、子查询
查询语文分数刚好是80分的人的姓名
select name from info where id=(select s.xid from score s inner join course c on c.id=s.cid where s.grade=80 and c.name='语文');
查询年龄比xx年龄大的人的姓名和年龄(子查询)
select name,age from info where age >(select age from info where name ='xx');
查询年龄比xx年龄大的人的姓名和年龄(子查询结果大于1个,用in)
select name,age from info where age in (select age form info where name='xx');
二、exists:只要括号里有一个成立就执行括号外的语句(类似于if else)
查询分数高于95分的人的编号和姓名
select id,name from info where exists(select xid from score where grade>95);