选择字段值不在数组中的所有字段 [英] Select all field where field value not in array

查看:26
本文介绍了选择字段值不在数组中的所有字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个变量中有这个数组

I have this array in a variable

$regions = |north|south|west|

和包含单个值的数据库字段区域",例如北

and a database field "Region" that contains a single value e.g. north

我需要一个 select 语句来选择Region"的值不是数组中列出的任何值的所有字段.例如北、南、西.

I need a select statement that will select all the fields where the value of "Region" is not any of the values listed in the array. e.g. north, south, west.

推荐答案

您可以在 SQL 中使用 WHERE field NOT IN('value1', 'value2', ...) 执行此操作.基本字符串函数可能足以让您的数组采用这种格式.

You can do this in SQL with WHERE field NOT IN('value1', 'value2', ...). Basic string functions are probably sufficient to get your array in this format.

这篇关于选择字段值不在数组中的所有字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆