+----+------------------------+
| id | name |
+----+------------------------+
| 2 | 1,2 |
| 33 | 2,44,33,5 |
| 1 | 11,4,55 |
| 12 | 11,111,122,551,112,221 |
+----+------------------------+
SELECT * 从test1 其中FIND_IN_SET( '122',名字)
将O/P以下:
+----+------------------------+
| id | name |
+----+------------------------+
| 12 | 11,111,122,551,112,221 |
+----+------------------------+
在SQL精简版,使用它将会是:
select *
from `test1`
where name like '%,122,%'
or name like '122,%'
or name like '%,122'
or name = '122'
的情况:
我的价值是551122。在这种情况下,值从申请返回,我们可以分割值列&编写查询作为
(',' || column_name || ',') LIKE '%,551,%' or
(',' || column_name || ',') LIKE '%,122,%'
来处理这个任何最好的主意?
我想避免像。那么还有其他想法吗?
+1
你可以使用'LIKE': http://stackoverflow.com/questions/6979813/alternative-to-find-in-set-in-sqlite/6980615#6980615 –
+0
我不明白你的评论? –
+0
我不认为你想要做什么可以在纯SQLite中完成,而不需要改变你的模式。可能会有第三方SQLite附加组件会根据您的需要使用数组数据类型,或者您可以编写自己的功能来执行您想要的功能。 –