The SQL EXISTS
operator executes the outer SQL query if the subquery is not NULL (empty result-set). For example,
SELECT customer_id, first_name
FROM Customers
WHERE EXISTS (
SELECT order_id
FROM Orders
WHERE Orders.customer_id = Customers.customer_id
);
Here is how the SQL command works:

This process is repeated for each row of the outer query.

Example 2: SQL EXISTS Operator
The below SQL query selects orders from the order table for customers who are older than 23 years.
SELECT *
FROM Orders
WHERE EXISTS (
SELECT customer_id
FROM Customers
WHERE Orders.customer_id = Customers.customer_id
AND Customers.age > 23
);