O'Reilly logo

Practical SQL Handbook, The: Using SQL Variants, Fourth Edition by Sandra L. Emerson, Marcy Darnovsky, Judith S. Bowman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Subqueries Introduced with Comparison Operators and ANY or ALL

Another kind of subquery, which returns any number of rows (including none) for the outer query, uses a comparison operator modified with keywords ALL or ANY. Subqueries introduced with a modified comparison operator take the following general form:

						Start of SELECT, INSERT, UPDATE, DELETE statement; or
						subquery
WHERE expression comparison_operator [ANY | ALL]
     (subquery)
[End of SELECT, INSERT, UPDATE, DELETE statement; or subquery]
					

Understanding ALL and ANY

Using the “>” comparison operator as an example, “> ALL” means greater than every value—in other words, greater than the largest value. In this way, “> ALL (1, 2, 3)” means greater than 3. “> ANY” means greater than at least ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required