如何查询表格的逗号分隔字段以查看数字是否在字段内 [英] How to query comma delimited field of table to see if number is within the field
本文介绍了如何查询表格的逗号分隔字段以查看数字是否在字段内的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果列包含特定数字(例如 981),我想从表中选择行.这些列中的数据为 0、空值或以下格式:
I want to select rows from a table if a column contains a certain number e.g 981. The data in these columns is either 0, null or in the format below:
1007,1035,1189,908,977,974,979,973,982,981,1007
我如何在查询中表达这一点?
How do I phrase this in a query?
显然下面的这个查询是不够的,但我需要类似的东西
Obvious this query below isn't sufficient but I need something similar
SELECT * FROM `table` WHERE `column`='981'
谢谢
推荐答案
如果您有正则表达式,它可能会起作用:
If you have regular expressions it may work:
SELECT * FROM `table` WHERE `column` REGEXP '(^|,)951($|,)'
这篇关于如何查询表格的逗号分隔字段以查看数字是否在字段内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文