多个类别(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;
多个类别(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;