J
J
jtag2017-09-22 13:21:40
MySQL
jtag, 2017-09-22 13:21:40

How to return only those rows that don't have an associated row in another table?

There are two tables person and sms. Linked to each other by id. Almost all person strings have an associated sms string. But some person strings don't have sms string yet, how to return only those person strings?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
V Sh., 2017-09-22
@JuniorNoobie

SELECT person.*
FROM person
LEFT JOIN sms ON sms.id = person.id
WHERE sms.id IS NULL

K
Konstantin Tsvetkov, 2017-09-22
@tsklab

In the query, link two tables LEFT OUTER JOIN and put a filter on an empty sms.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question