We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
any 、 all 、 some 是子查询关键词之一,必须与一个比较操作符进行一起使用。
any
all
some
true
!=
create table t1 (id int, value int); create table t2 (id int, value int); insert into t1 values(1, 10), (2, 300), (3, 40), (4, 60), (5, 70), (6, 80); insert into t2 values(1, 100), (2, 300), (3, 40), (4, 600), (5, 70), (6, 800);
select * from t1 where value <= all( select value from t2 );
t2
value
(100, 300, 40, 600, 70, 800)
t1
value <= all(100, 300, 40, 600, 70, 800)
value = 10
value = 300
false
null
select * from t1 where value <= any( select value from t2 );
value <= (100, 300, 40, 600, 70, 800)
select * from t1 where value != some( select value from t2 );
t1 表中有部分 value 与 t2 表中的 value 不相等
如果用 any 就会理解成:t1 表中的 value 与 t2 表中的任意 value 不相等。
他们结果是一样的。
The text was updated successfully, but these errors were encountered:
No branches or pull requests
any
、all
、some
是子查询关键词之一,必须与一个比较操作符进行一起使用。any
和子查询返回的列中 任一值 比较为true
则返回为true
。all
和子查询返回的列中 所有值 比较为true
则返回为true
。some
的用法和any
一样,在!=
的场景中,用any
容易产生误解,用some
更容易理解all
方法t2
表中所有的value
,结果为(100, 300, 40, 600, 70, 800)
t1
表中筛选value <= all(100, 300, 40, 600, 70, 800)
value = 10
,它小于等于(100, 300, 40, 600, 70, 800)
里所有的值,结果为true
value = 300
它没有小于等于(100, 300, 40, 600, 70, 800)
里所有的值,结果为false
tips
true
null
,结果为false
,也就是说查不出结果null
,结果为false
,和结果为空不是一个概念any
方法t2
表中所有的value
,结果为(100, 300, 40, 600, 70, 800)
t1
表中筛选value <= (100, 300, 40, 600, 70, 800)
value = 10
,它小于等于(100, 300, 40, 600, 70, 800)
里任一的值,结果为true
value = 300
它没有小于等于(100, 300, 40, 600, 70, 800)
里任一的值,结果为true
tips:
false
,也就是说查不出结果null
,结果为false
some
用法t1
表中有部分value
与t2
表中的value
不相等如果用
any
就会理解成:t1
表中的value
与t2
表中的任意value
不相等。他们结果是一样的。
The text was updated successfully, but these errors were encountered: