MySQL select rows that do not have matching column in other table

Typically, you would use NOT EXISTS for this type of query

SELECT p.Name
FROM   pooltest p
WHERE  NOT EXISTS (SELECT s.Name
                   FROM   senttest s
                   WHERE  s.Name = p.Name)

An alternative would be to use a LEFT OUTER JOIN and check for NULL

SELECT p.Name
FROM   pooltest p
       LEFT OUTER JOIN senttest s ON s.Name = p.Name
WHERE  s.Name IS NULL

Note that the implicit join syntax you are using is considered obsolete and should be replaced with an explicit join.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)