use E_Market
go
--[1]>all父查询的列的值必须大于子查询返回的值列表中的每一个值
select * from table2 where n > all ( select n from table1)

--返回结果为4
--table2(1,2,3,4)
--table1(2,3)

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

--[2]>any 父查询的列中的值至少大于子查询返回值列表中的一个值
select * from table2 where n > any ( select n from table1)

--结果为3和4

--[3]改为some的形式,some和any的功能一样
select * from table2 where n > some ( select n from table1)

--结果为3和4

--【4】=any与子查询中的in是等效的,父查询中列的值,必须在子查询返回的列表中存在
select * from table2 where n = any ( select n from table1)
select * from table2 where n in ( select n from table1)

--结果均为2,3

--【5】<>any与not in
select * from table2 where n <> any ( select n from table1)
select * from table2 where n not in ( select n from table1)

--<>any:结果为1,2,3,4
--not in:结果为1,4

--<>any:父查询的结果中列的值与子查询返回的值列表中的一个不相同就可以
--not in:父查询的结果中列的值必须不能存在在子查询返回值的列表中

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄