多个类别(catid)下面存在同名商品(name),查询结果会出现约定分类以外的同名商品,帮我看下这个语句有什么问题,谢谢!
select id,catid,name from products where name in (select name from products where find_in_set(catid,'2,5') group by name having count(name)>1) order by name;
select id,catid,name from products where catid in (find_in_set(catid,'2,5')) and name in (select name from products where find_in_set(catid,'2,5') group by name having count(name)>1) order by name;
谢谢老师,外面查询忘了加这个条件了。
select id,catid,name from products where (find_in_set(catid,'2,5')) and name in (select name from products where find_in_set(catid,'2,5') group by name having count(name)>1) order by name;
您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~
如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~
ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632