SQL Keyword - ALL

ALL Keyword

The ALL keyword or command is used to check logical conditions.

The ALL Keyword is a logical operator that compares single value with a single-column set of values returned by a subquery.

The ALL command returns the boolean value True Or False.

Return True if all of the subquery values match the condition.

Syntax

ALL Operator with Select Query

SELECT ALL <COLUMN_NAME> FROM <TABLE_NAME> WHERE <CONDITION>;

Example

SELECT ALL Emp_Name FROM Employee WHERE Emp_Age < 30 ;

Syntax

ALL Operator with Where Clause or Having Clause,

SELECT <COLUMN_NAMES> FROM <TABLE_NAME> WHERE <COLUMN_NAME> ALL (SUBQUERY);

Example

SELECT Emp_Id,Emp_Name,Emp_Salary FROM Employee WHERE Emp_Salary > ALL (SELECT Emp_Salary FROM Employee WHERE Emp_Id = 101);

Summary

ALL Keyword returns TRUE, if all the mentioned sub-queries values meet the conditions.

Next Recommended Reading SQL Keyword - ADD