ANY

SQL ANY Keyword

The ANY keyword in SQL is used to compare a value to any value in a subquery. It returns TRUE if at least one of the values returned by the subquery satisfies the condition.

Tutorials dojo strip

SQL ANY Syntax

SELECT column1, column2, ...
FROM table_name
WHERE column operator ANY (SELECT column FROM table_name WHERE condition);

SQL ANY Example with Prescriptions Table

This query selects medication names from the Prescriptions table where the dosage matches any dosage used in prescriptions with the instruction 'Take once daily at bedtime.'. This query returns all medications where the dosage equals any dosage found in prescriptions that include the given instruction.

SELECT medication_name
FROM Prescriptions
WHERE dosage = ANY (
  SELECT dosage
  FROM Prescriptions
  WHERE instructions = 'Take once daily at bedtime.'
);

Note: This query will not work in our playground because the ANY keyword is not supported in SQLite, which is the engine used by TechKubo.

SQL ANY Labs

Tutorials dojo strip
Scroll to Top