准备两个表:
–T1(2,3)
–T2(1,2,3,4)
–ALL,ANY,SOME 的子查询
— >ALL 父查询中的结果集大于子查询中每一个结果集中的值,则为真
SELECT * FROM T2 WHERE N>ALL (SELECT N FROM T1)
— >ANY,SOME 父查询中的结果集大于子查询中任意一个结果集中的值,则为真
SELECT * FROM T2 WHERE N>ANY(SELECT N FROM T1)
SELECT * FROM T2 WHERE N>SOME(SELECT N FROM T1)
— =ANY 与子查询IN相同
SELECT * FROM T2 WHERE N=ANY (SELECT N FROM T1)
SELECT * FROM T2 WHERE N IN (SELECT N FROM T1)
— <>ANY 与NOT IN
–<>ANY
–OR作用 父查询中的结果集不等于子查询中的a或者b或者c,则为真
SELECT * FROM T2 WHERE N <>ANY(SELECT * FROM T1)
–NOT IN
–AND作用 父查询中的结果集不等于子查询中任意一个结果集中的值,则为真
SELECT * FROM T2 WHERE N NOT IN(SELECT * FROM T1)