Account
Categories

EXISTS Operator


EXISTS:
In MySQL, when you use the EXISTS operator in the query, it checks the data.
If data is found, then the query returns one or more rows and returns TRUE; otherwise, it returns FALSE.

Syntax:

    SELECT employee_name
    FROM employees e
    WHERE EXISTS (
    SELECT 1
    FROM salaries s
    WHERE s.employee_id = e.employee_id
    AND s.salary > 50000
);