The SQL EXISTS Operator with WHERE condition. The following SQL query shows how to use EXISTS while querying data from the database.
SQL EXISTS Syntax:
SELECT column, column, ....
FROM table_name
WHERE EXISTS
(SELECT column FROM tablename WHERE condition);
Example:
SELECT name
FROM employees
WHERE EXISTS (SELECT amount FROM payments WHERE employee.id = payments.employee_id);