Lukas Eder discusses the ALL, SOME, and ANY predicates:
Ultimately, you should always choose performance first, and then – most certainly – intuitiveness second (because some poor soul might need to maintain your query). But personally, I find these quantifiers quite elegant for three reasons:
-
They express the quantification right where it belongs. With the comparison operator. Compare this with the solution using LIMIT, which may be far away, visually, from the greater-than operator. Quantifiers are much more concise, even than when using MAX() (in my opinion)
-
They’re very set oriented. I like thinking in terms of sets when I work with SQL. Whenever I can omit the
ORDER BY
clause, I will. If only to avoid potentially slow operations (in case the database doesn’t optimise this, and a fullO(N log N)
sort operation is invoked) -
Quantified comparison predicates work on rows too, not just on single values.
I’ve known about these, but could probably count on one hand the number of times I’ve ever used one.