就是查询的查询,多个查询嵌套,一般从最里面开始。比较耗性能,也可以用内连
select bdesc from branches where cid=(select cid from client where cname ="Rabbit")
一些例子:
select cname from clients where cid= (select cid,count(bid) from branches group by cid having count(bid) = 2) //可以查询多个,用in select sname from services where sid in (select sid from branches_services where bid =1031) //用exist判断是否存在 select * from clients where exists (select bid from branches_service group by bid having count(bid) > 2) select avg(s.stotal) from (select bid,count(sid) as stotal from branches_services group by bid) as s;