1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > mysql any some和all的用法

mysql any some和all的用法

时间:2019-10-30 00:21:56

相关推荐

mysql any some和all的用法

1.ANY关键字

假设any内部的查询语句返回的结果个数是三个,如:result1,result2,result3,那么,

select ...from ... where a > any(...);

->

select ...from ... where a > result1 or a > result2 or a > result3;

即a大于子查询中的任意一个,等同于a大于子查询的最小值即可。

2.ALL关键字

ALL关键字与any关键字类似,只不过上面的or改成and。即:

select ...from ... where a > all(...);

->

select ...from ... where a > result1 and a > result2 and a > result3;

即a大于子查询中的每一个,等同于a大于子查询的最大值。

3.SOME关键字

some关键字和any关键字是一样的功能。所以:

select ...from ... where a > some(...);

->

select ...from ... where a > result1 or a > result2 or a > result3;

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