Last Updated: March 14, 2022
EXISTS is used to check subquery has rows or not. If the subquery has rows it returns TRUE else it returns FALSE.
SELECT column_name(s) FROM table_name WHERE EXISTS (SELECT column_name FROM table_name WHERE condition);
Get the list of customers who have at least one order.
SELECT customer_name FROM customers WHERE EXISTS (SELECT 1 FROM orders WHERE customers.id = orders.id);