While *Delete* the multiple rows using column value, getting "update you can't specify target table for update in from clause" this error in mysql

Viewed 23

I'm using the below DELETE query.

DELETE FROM tableAA WHERE id IN (SELECT id FROM tableAA WHERE coreID IN (SELECT fill_ID FROM tableBBB) and columnData= 'data');

but I am getting this "update you can't specify target table for update in from clause" error.

2 Answers

Sorry, i can not check my example right now:

DELETE FROM tableAA LEFT JOIN tableAA.id = fill_ID.tableBBB WHERE fill_ID NOT IS NULL and columnData = data;

Try with this one:

DELETE FROM tableAA 
WHERE coreID IN (SELECT fill_ID FROM tableBBB)
  AND columnData = 'data';
Related