就是在简单查询中嵌套查询(where子句里面嵌套)
select name from tablename where id in ( select id from tablename where num in (100,101) )
可以一直嵌套下去
但是由于性能的限制,实际上不能嵌套太多的子查询
当然,不一定是in
,其他也行
或者在select子句里进行嵌套
select name,( select * count(distinct name) from tablename ) as other from tablename order by name;
在from子句里面嵌套
select * from (select id,name from tablename order by id) as other
还可以在exists
等子句内嵌套