300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > all any some查询

all any some查询

时间:2019-09-05 11:18:07

相关推荐

all  any  some查询

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)

--[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:父查询的结果中列的值必须不能存在在子查询返回值的列表中

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。