EXISTS in MySQL — How It Works

What the MySQL EXISTS function does, with an example.

Published October 22, 2026

EXISTS tests whether a subquery returns any rows, returning true or false.

Key points

  • Part of standard SQL functions available in MySQL for working with query results

Example

SELECT * FROM users u WHERE EXISTS (SELECT 1 FROM orders o WHERE o.user_id = u.id);
More SQL articles