Delete statement in a same table

Viewed 27226

I need to query a delete statement for the same table based on column conditions from the same table for a correlated subquery.

I can't directly run a delete statement and check a condition for the same table in mysql for a correlated subquery.

I want to know whether using temp table will affect mysql's memory/performance?

Any help will be highly appreciated.

Thanks.

7 Answers

I have used group by aggregate with having clause and same table, where the query was like

DELETE 
FROM TableName
WHERE id in 
   (select implicitTable.id 
    FROM (
          SELECT id 
          FROM `TableName` 
          GROUP by id 
          HAVING count(id)>1
          ) as implicitTable
   )
Related