In this tutorial, we will learn about MySQL ALL Operator with example. The ALL operator is quantified comparison operator. The quantifier keywords ALL, ANY, and SOME allow comparison with multiple rows.
To perform a comparison between a scalar value and a subquery that returns several rows of data
in a column subquery, we must use a quantified comparison.
We can use the ALL comparison operator construct in a comparison with a column subquery limits the result set to only those rows where the comparison is true for all values produced by the subquery.
In this example, we will use the City table from the world MySQL database.
Let’s find the names of cities which have population greater than all the cities in the United States. We can use the ALL operator against the column subquery that returns the rows of the Population column from the City table where the country code matches USA.
mysql> SELECT Name FROM City
-> WHERE Population >
-> ALL (SELECT Population FROM City
-> WHERE CountryCode =’USA’);
| Name |
| SÃ£o Paulo |
| Jakarta |
| Mumbai (Bombay) |
| Shanghai |
| Seoul |
| Ciudad de MÃ©xico |
| Karachi |
| Istanbul |
| Moscow |
9 rows in set (0.01 sec)
MySQL Tutorials on this website:
For more information on MySQL Database: