MySQL Forums
Forum List  »  General

Re: Best way to simulate a "join" and "limit" during DELETE
Posted by: Peter Brawley
Date: August 09, 2022 05:05AM

All three ought to work. Semi-joins like IN() are better optimised in more recent versions, so something like ...

set @id = ( select id from ... where name='Bob'
delete from ... where id=@id;

... or ...

delete from posts where postid = (select userid from users where username='bob');

... or several such variations.

If you're unsure, first run the corresponding SELECT first to verify that you have the scope right.

Options: ReplyQuote


Subject
Written By
Posted
Re: Best way to simulate a "join" and "limit" during DELETE
August 09, 2022 05:05AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.