A subquery refers to nesting another SELECT statement in a SELECT statement.
Any,in,some,all is one of the sub-query keywords,
Any can be used with =, >, >=, <, <=, <> to represent equal, greater than, greater than, equal to, less than, less than or equal to, and not equal to any one of the data.
All can be used with =, >, >=, <, <=, <>, respectively, to represent all data equal to, greater than, greater than or equal to, less than, less than or equal to, and not equal to any of them.
The syntax for their subquery is as follows:
Some all (subquery);
The Any,all keyword must be used with a comparison operator. The Any keyword can be interpreted as "returns true for any value in the column returned by the subquery if the comparison evaluates to True."
For example:
Select from where > any (Select from T2);
If there is a row in table T1 containing (ten), T2 contains (21,14,6), the expression is true, if T2 contains (20,10), or the table T2 is an empty table, the expression is false. If the table T2 contains (null,null,null), the expression is unkonwn.
All means "returns true for all values in the column returned by the subquery if the comparison evaluates to True"
For example:
Select from where > All (Select from T2);
Suppose a row in table T1 contains (10). If the table T2 contains ( -5,0,+5), the expression is true because 10 is larger than all three values found in T2. If the table T2 contains (12,6,null,-100), the expression is false because there is a value of 12 greater than 10 in T2. If the table T2 contains (0,null,1), the expression is unknown. If T2 is an empty table, the result is true.
not in is the alias of "<>all", the same usage.
The statement in is the same as "=any".
For example:
Select from where = any (Select from T2); Select from where inch (Select from T2);
The statement some is an alias of any and uses the same.
For example:
Select from where <> any (Select from T2); Select from where <> some (Select from T2);
In the above query some understanding is easy to "table T1 in some S1 and T2 table S1 unequal", this statement with any understanding is wrong.
"MySQL" in MySQL any,in,some,all differences