There are fields for products that contain keys (for groups). You need to select their id from the first entry that you have, without repetitions (if they have the same keys that are not known in advance) For example, there are

 id key 1 44 2 44 3 66 4 66 5 77 

It should work -> 1,3,5 tried SELECT id FROM table GROUP BY key HAVING COUNT(*) = 1 - did not work

  • And where in your example will take 7? - Darevill
  • wrong, corrected. In any case, your answer helped, pushed the extra count - ddeadlink

2 answers 2

Group by key

 SELECT `id` FROM `table` GROUP BY `key` 
     select min(id) from table group by key