There is a request

select `id`, `name`, `sublink` from cms_es_cats where sublink LIKE 'products/ucenennye-tovary%' 

I tried this:

 select id, id_parent, name, sublink from cms_es_cats where sublink LIKE 'products/ucenennye-tovary%' GROUP BY sublink HAVING count(sublink)>1; 

but prints only 1 duplicate string, and I also need all its duplicates.

How to add / add a query to output lines with only the same values ​​of the sublink field?

  • look towards grouping across the sublink field and further having - Dmitriy Gvozd
  • corrected the question. - amijin 4:21 pm

1 answer 1

As one of possible options, to use the enclosed request, together with construction IN

 SELECT id, id_parent, name, sublink FROM cms_es_cats WHERE sublink IN (SELECT sublink FROM cms_es_cats WHERE sublink LIKE 'products/ucenennye-tovary%' GROUP BY sublink HAVING count(sublink) > 1);