MySQL + SQL · Lesson 74

ANY and ALL Operators

ANY and ALL

ANY and ALL compare a value to a set of values from a subquery.
  • > ANY = greater than at least one.
  • > ALL = greater than every one.

Examples

-- marks greater than ANY class-10 student (i.e. > the minimum)
SELECT name FROM students
WHERE marks > ANY (SELECT marks FROM students WHERE class = '10');

-- marks greater than ALL class-10 students (i.e. > the maximum)
SELECT name FROM students
WHERE marks > ALL (SELECT marks FROM students WHERE class = '10');

Summary

  • > ANY = greater than the smallest in the set.
  • > ALL = greater than the largest in the set.
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

💻 Live Code Editor

This page's programs are ready here — run them, edit them, and learn. No installation needed.
Powered by OneCompiler. The code loads into the editor automatically — press Run to see the output. If the editor does not open, open it in a new tab.