例如:A表,id name
1 中药,西药
2 西药 ,西药
3 西药
统计出 name中只有西药的,但name不能有中药(例如id为1的就不要统计)
select name
from A
where name="西药"
select * from A where replace(replace(name,'西药',''),',','') = '' ;
不行,还是都能统计出来
select * from A where name like '%西药%' and name not like '%中药%'
我加了个trim,你自己测试一下吧,我测试是好用的