Reputation: 9662
I need some help with MySQL query. I have a list of product color ids and I want to find out which one of those don't exist in the database. The below query returns the matching colorids from the database. I want to see which of the colors don't exists in db.
select cs.imageid from colorids cs
where cs.imageid in
(
3333,
2222,
4444,
5555,
6666,
7777,
8888,
)
Upvotes: 0
Views: 352
Reputation: 49079
You can hard-code your list this way, and then use a LEFT JOIN:
SELECT list.colorid
FROM (
SELECT 3333 colorid
UNION ALL
SELECT 2222
UNION ALL
SELECT 4444
) AS list LEFT JOIN colorids cs
ON list.colorid = cs.imageid
WHERE
cs.imageid IS NULL
Upvotes: 2