I'm trying to SELECT entries of a certain type, name, EXCLUDING entries with the same name in a particular id. The last part is the tricky part that I can't get my head around.
SELECT name FROM table WHERE type = $type AND (name is not contained in an entry with id).
I want the result to be the set of all names that ARE of a certain type but NOT already included in a current id.
Do I need to execute two queries here? Or can I condense it to one.
Thanks.
You can use a subquery for this:
SELECT name
FROM table
WHERE type = $type
AND name NOT IN (SELECT entry FROM t WHERE id = $id );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With