Page 1 of 1

You can't specify target table 'downloads' for update ?

Posted: Thu Jul 29, 2010 11:06 am
by mayanktalwar1988
in phpmyadmin when i ran this query

Code: Select all

delete from downloads where id not in (select max(id) from downloads  group by downloadlink)
it throws this error

Code: Select all

#1093 - You can't specify target table 'downloads' for update in FROM clause
actualyy i m deleting duplicate rows based on one column for which i m checking duplicate..i group the results by duplicate column ..then id is the autoincrement key..after that i delete all rows in group except the one that has max id..so logic is correct i think but its not running..

Re: You can't specify target table 'downloads' for update ?

Posted: Thu Jul 29, 2010 11:28 am
by Darhazer
You cannot update a table / delete from table and use the same table in a subquery.
You can however lock the table, select the IDs and then perform deletion.