Checking if a mysql row is NOT in an array

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 08:59:18

问题


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:


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) 


来源:https://stackoverflow.com/questions/6873734/checking-if-a-mysql-row-is-not-in-an-array

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!