子查询
---IN---
select * from foo where id in (select max(id) from foo );
select * from foo where id NOT in (select max(id) from foo );
---EXISTS---
select * from foo where EXISTS (select 语句,次语句如果查询到值括号为true,否则括号内的值为false);
-->此关键字(EXISTS)后面的查询(我意思说后面括号内的查询)会返回一个值,记作val
如果val为空,前面的查询不执行
如果val不为空,前面的查询执行
selecgt * from foo where NOT EXISTS(select....);
---ANY---
select * from t1 where col_x > ANY (select col_y from t2);
-->外查询大于任意子查询的所有记录被取出
---ALL---
select * from t1 where col_x > ALL(select col_y from t2);
-->外查询大于所有子查询记录的记录被取出
---------------------------------------------------------------------------------------------------------------
浙公网安备 33010602011771号