开发者

Checking if a mysql row is NOT in an array

开发者 https://www.devze.com 2023-03-24 00:16 出处:网络
I know that you can use WHERE `age` IN ($ages) 开发者_运维技巧to find rows where the column age equals a part of an array.

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


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) 
0

精彩评论

暂无评论...
验证码 换一张
取 消