Usage of all in mysql: 1. all means "for all values in the column returned by the subquery, if the comparison result is true, then return true"; 2. all can be used with [=, >, >=, <, <=, <>] are used in combination to mean equal to, greater than, greater than or equal to, less than, less than or equal to, and not equal to, respectively.
Usage of all in mysql:
I have been practicing multi-table queries of MYSQL recently, basically every I always write a query statement at least twice: once for join connection and once for subquery. Let’s compare the working methods and efficiency of MYSQL under different query methods. There are keywords such as any, all, and some in the subquery.
The any,all keywords must be used together with a comparison operator. The any keyword can be understood as "for any value in the column returned by the subquery, if the comparison result is true, then return true". all means "for all values in the column returned by the subquery, if the comparison result is true, then return true"
any can be used with =, >, >=, <, <= , <> are used in combination to represent data equal to, greater than, greater than or equal to, less than, less than or equal to, or not equal to any one of them.
all can be used in combination with =, >, >=, <, <=, <> to mean equal to, greater than, greater than or equal to, less than, less than or equal to, and not equal to, respectively. all the data in it.
For example:
select s1 from t1 where s1 > any (select s1 from t2);
Assume that s1 after any returns three values, then In fact, it is equivalent to
select s1 from t1 where s1 > result1 or s1 > result2 or s2 > result3
And the usage of all is equivalent to buffering the 'or' of the above statement 'and'
Speaking of this, you may already know that any and or are often used to compare two tables. When you don't know the specific value behind where, you can use any and all to help you determine.
More related free learning recommendations: mysql tutorial(Video)
The above is the detailed content of What is the usage of all in mysql. For more information, please follow other related articles on the PHP Chinese website!