1

I know that you can use

WHERE `age` IN ($ages) 

to find rows where the column age equals a part of an array.

But what i need to find out is - What if you want to find rows where age is NOT in the array??

thanks

1
  • Can't you just do WHERE age` NOT IN ($ages)` Commented Jul 29, 2011 at 13:20

1 Answer 1

10

You need NOT IN. Yep, it really is that simple.

$ages = "1,3,4,7,9";

// Your SQL WHERE clause...
WHERE `age` NOT IN ($ages) 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.