I want to select everything from the product table where the name is not equal to a name existing in ordered_products. I tried this but it didnt work:
SELECT * FROM product WHERE naam IS NOT (SELECT naam FROM ordered_products)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use the
NOT INpredicate like so:But this is not safe, in case there is any
NULLvalues of thenaamcoming from the other table, thats why I addedWHERE naam IS NOT NULLto the subquery. Better off, useJOINlike so: