ultrus Posted February 16, 2012 Share Posted February 16, 2012 Hello Gurus, I'm trying to delete rows from a table, but would need to join in some data from another table (that I don't want to delete from), use an embedded SELECT statement, or run multiple queries (don't want to do that last one). Query: DELETE FROM event_guest WHERE guest_id IN (SELECT eg.guest_id FROM event_guest eg LEFT JOIN guest g ON g.id = eg.guest_id WHERE g.attendee_id = '2') Error: #1093 - You can't specify target table 'event_guest' for update in FROM clause But this part works: (SELECT eg.guest_id FROM event_guest eg LEFT JOIN guest g ON g.id = eg.guest_id WHERE g.attendee_id = '2') Any thoughts on how to restructure this correctly? Thanks a ton in advance!! Link to comment https://forums.phpfreaks.com/topic/257143-having-trouble-deleting-rows-from-single-table-based-on-ids-from-another-select/ Share on other sites More sharing options...
ultrus Posted February 16, 2012 Author Share Posted February 16, 2012 I may have found an answer here: http://stackoverflow.com/questions/9285143/mysql-you-cant-specify-target-table-a-for-update-in-from-clause Link to comment https://forums.phpfreaks.com/topic/257143-having-trouble-deleting-rows-from-single-table-based-on-ids-from-another-select/#findComment-1318174 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.