SQL 2023 · Joins and combining queries

Check that related rows exist

Return users that have at least one order. EXISTS stops at the first match.

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

Official SQL 2023 documentation

More joins and combining queries commands

All joins and combining queries commands · SQL 2023 cheatsheet

Was this page helpful?