I have a table taged with two fields sesskey (varchar32 , index) and products (int11), now I have to delete all rows that having group by sesskey count(*) = 1. I\'m trying a
DELETE si FROM t_session si JOIN ( SELECT sesskey FROM t_session so GROUP BY sesskey HAVING COUNT(*) = 1 ) q ON q.sesskey = si.sesskey
You need to have a join here. Using a correlated subquery won't work.
See this article in my blog for more detail: