My Sql Table Like this. 从表中检索数据并从此值中计算特定数据。如果给定 no 为 6,则表示计数为 4。
+---------+-------------+-------------+
| id | Values |
+---------+-------------+-------------+
| 11 | 1,2,4,5,6 |
| 12 | 1,2,6 |
| 13 | 4,5,6 |
| 14 | 2,3,6 |
+---------+------------+--------------+
您可以使用find_in_set
从逗号分隔的字符串中搜索值
select count(*) total
from demo
where find_in_set(6, `Values`) > 0;
演示