Checking whether an item does not exist in another table

In general if you want rows that don’t exist in another table, then LEFT JOIN the other table and WHERE … IS NULL to a column on the second table. Also you mentioned that you don’t want rows where process.id_string is NULL.

SELECT p.name, p.id_string
FROM
    process p
    LEFT JOIN value_search v
        ON v.id_string = p.id_string
WHERE
    v.id_string IS NULL
    AND p.id_string IS NOT NULL

This is known as an anti-join.

Leave a Comment

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