mysql> select id,name,service_project_ids FROM `laifu_service_diseases&problems` where service_project_ids LIKE '25' OR service_project_ids LIKE '25,%' -> OR service_project_ids LIKE '%,25,%' OR service_project_ids LIKE '%,25'; +----+-----------------+---------------------+ | id | name | service_project_ids | +----+-----------------+---------------------+ | 1 | 心血管疾病 | 25 | | 2 | 肝病 | 2,25,3 | | 5 | 胃病 | 3,4,25 | +----+-----------------+---------------------+ 3 rows in set (0.000082 sec)
find_in_set()
1 2 3 4 5 6 7 8 9
mysql> select id,name,service_project_ids FROM `laifu_service_diseases&problems` where find_in_set(25,service_project_ids); +----+-----------------+---------------------+ | id | name | service_project_ids | +----+-----------------+---------------------+ | 1 | 心血管疾病 | 25 | | 2 | 肝病 | 2,25,3 | | 5 | 胃病 | 3,4,25 | +----+-----------------+---------------------+ 3 rows in set (0.000086 sec)
locate()
1 2 3 4 5 6 7 8 9 10
mysql> select id,name,service_project_ids FROM `laifu_service_diseases&problems` where locate(25,service_project_ids); +----+-----------------+---------------------+ | id | name | service_project_ids | +----+-----------------+---------------------+ | 1 | 心血管疾病 | 25 | | 2 | 肝病 | 2,25,3 | | 5 | 胃病 | 3,4,25 | | 7 | 肠胃病 | 5,1256 | +----+-----------------+---------------------+ 4 rows in set (0.000592 sec)
INSTR()
1 2 3 4 5 6 7 8 9 10
mysql> select id,name,service_project_ids FROM `laifu_service_diseases&problems` where INSTR(service_project_ids,25); +----+-----------------+---------------------+ | id | name | service_project_ids | +----+-----------------+---------------------+ | 1 | 心血管疾病 | 25 | | 2 | 肝病 | 2,25,3 | | 5 | 胃病 | 3,4,25 | | 7 | 肠胃病 | 5,1256 | +----+-----------------+---------------------+ 4 rows in set (0.000799 sec)