How can I show records that have no related row in another table?
Quick answer
To find members with no matching payment, use either a LEFT JOIN and filter for NULL in a payment column that cannot be NULL for a real match, or use NOT EXISTS with a correlated subquery. Both patterns return members for whom no payment row has the same member key. Replace the example table and column names with yours, and choose the NULL-check column carefully. [S1] [S2]
The question, the details, the next step.
A practical checklist
Name the left table whose unmatched records you want.
Confirm the exact key relationship between the two tables.
For LEFT JOIN, select a right-side column that is never NULL on a real match.
For NOT EXISTS, put the matching-key condition in the correlated subquery.
Test the query against a few records whose relationships you can verify.
A few more useful answers
Can the LEFT JOIN version return a member more than once?
Yes, the join can produce one row per matching payment, but those matched rows are removed by the NULL test. Unmatched members appear as rows with NULL right-side columns.
Does NOT EXISTS depend on what I put after SELECT?
In SQLite, EXISTS depends on whether the subquery returns any rows, not on the selected values. SELECT 1 is a concise way to express that the subquery is checking for a match. [S2]
What if my table has a different relationship key?
Replace the example keys with the actual columns that define the relationship, and use that same match condition in either query. The examples cannot determine which columns in your database are correct.
Sources
References used for this guide.
- [S1] SQLite SELECT — LEFT JOIN and NULL-filled unmatched rows sqlite.org · Checked
- [S2] SQLite SQL expressions — EXISTS and correlated subqueries sqlite.org · Checked
