SQL some any all

回顾一下some any all 用法

userinfo表里面有100条数据,其中一个用户名为qixuejia.

1.some,any用法一样(不知道有没有其他的不同)

select  count(*) from userinfo
where 'qixuejia' <> some(select userid from userinfo)

where 条件成立 该条语句返回100.

2.all

select  count(*) from userinfo
where 'qixuejia' <> all(select userid from userinfo)

该where语句判断qixuejia不等于所有的userid,返回否.

所以该语句返回0

3.select  count(*) from userinfo
where 'qixuejia' in (select userid from userinfo)
返回100

4.select  count(*) from userinfo
where userid='qixuejia'
返回1

5.select  count(*) from userinfo
where 'qixuejia' not in (select userid from userinfo)

返回0

原文地址:https://www.cnblogs.com/qixuejia/p/1774452.html