What does the following pattern detect? SELECT a.id FROM tableA a WHERE NOT EXISTS (SELECT 1 FROM tableB b WHERE b.a_id = a.id)

SQL Fundamentals Hard

SQL Fundamentals — Hard

What does the following pattern detect? SELECT a.id FROM tableA a WHERE NOT EXISTS (SELECT 1 FROM tableB b WHERE b.a_id = a.id)

Key points

  • The query checks for absence of matching rows in tableB
  • It uses a subquery to compare values between tables
  • The result is a list of rows from tableA without matches in tableB

Ready to go further?

Related questions