简体   繁体   English

如何检查数组是否包含 sql 中的特定字符串

[英]how to check if array contains specific string in sql

I am trying to check if column contains string for example i have the following arrays;我正在尝试检查列是否包含字符串,例如我有以下 arrays;

['1','2']
['1']
['1','2','3']

I need to make an sql query to find if any of the arrays contains for example 1 so far i tried to use 'like' and 'in' but it doesn't seem to work我需要进行 sql 查询以查找是否有任何 arrays 包含例如 1 到目前为止我尝试使用“喜欢”和“在”但它似乎不起作用

我不知道你的表名或列名是什么,但如果这些例子代表单列数据,like 子句应该有效;

  select * from TABLE where COLUMN like '%1%'

You need to specify the index of the array where you are checking您需要指定要检查的数组的索引

    select * from TABLE where COLUMN[1] like '%1%'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM