ANY
ANY allows a WHERE or HAVING condition to pass if any of its subquery conditions are true. It returns TRUE if any of the subquery values satisfy the condition. ANY must be accompanied by a comparison operator.
Example
Output
Explanation
The SQL ANY operator is used to compare a value to any applicable value in the list. In the provided query, the ANY operator is used in a subquery to fetch any employee names from the employee
table where employee_salary
is greater than the salary of any employee in the department_id = 3
. The output is the list of employees who satisfy this condition.
Example
Output
Explanation
The ANY
operator in the SELECT
statement is used to compare a value with any value in a list. In this case, it returns employees who are earning more than any manager.
Example
Output
Explanation
The ANY
operator in SQL is used to compare a value with any or some of a set of values. In this example, it’s used to select employee names from the Employees
table where their salary exceeds the salary of any employee in the Sales
department. If any of the salaries in the Sales department are less than an employee’s salary in the broader Employees table, that employee’s name will be included in the output.
Example
Output
Explanation
In this example, the ‘ANY’ keyword is used in a subquery to compare the salary of each record in the ‘employees’ table to the salaries of employees with the ‘IT_PROG’ job id. If an employee’s salary is greater than any of these salaries, their first and last name are selected for the output.