There is a table
products with fields
id_parent … The field with a non-unique value is
id_parent . The goal is to get the number of unique
id_parent values that match the conditions. The construction below does not work, there are clearly more records returned than the number of unique and satisfying conditions. I ask for advice in drawing up the correct request.
$ query = "SELECT count (` id_product`) FROM `products` WHERE `title` LIKE '%". $ Title. "%' AND `visibility` = '' group by `id_parent` ";
SELECT count (distinct id_parent) FROM `products` WHERE `title` LIKE '%". $ Title. "%' AND `visibility` = ''