Jump to content

Having trouble deleting rows from single table based on ids from another SELECT


ultrus

Recommended Posts

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!!

 

:D

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.