MySQL Forums
Forum List  »  Newbie

Re: Delete and select in the same query
Posted by: Peter Brawley
Date: September 29, 2014 11:47AM

What's your objection to posting the result of ...

Show Create Table comments;

?!?

Well, whatever it is, we don't have the info, so I'll suppose that the table has a primary key column named ID: then the IDs of user N's comments and replies to them are ...

select ID from comments where user_id=N;
union
select ID from comments a
join comments b on a.id_parent=b.id_comment
where b.user_id=N;

Options: ReplyQuote


Subject
Written By
Posted
September 28, 2014 02:59AM
Re: Delete and select in the same query
September 29, 2014 11:47AM


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.