My Sql Table Like this. Retrieve data from table and Count Particular data from this values.If given no is 6 means the count is 4.
我的Sql表是这样的。从表中检索数据并从这些值中计数特定的数据。如果给出no是6表示计数为4。
+---------+-------------+-------------+
| id | Values |
+---------+-------------+-------------+
| 11 | 1,2,4,5,6 |
| 12 | 1,2,6 |
| 13 | 4,5,6 |
| 14 | 2,3,6 |
+---------+------------+--------------+
1 个解决方案
#1
5
You can use find_in_set
to search the value from comma separated string
您可以使用find_in_set从逗号分隔的字符串中搜索值
select count(*) total
from demo
where find_in_set(6, `Values`) > 0;
演示
#1
5
You can use find_in_set
to search the value from comma separated string
您可以使用find_in_set从逗号分隔的字符串中搜索值
select count(*) total
from demo
where find_in_set(6, `Values`) > 0;
演示