MySQL Forums
Forum List  »  Newbie

Re: update & select but return the results of the select
Posted by: Phillip Ward
Date: July 31, 2014 05:47AM

You can't invent syntax.
If you want to do an update and then select some data, then you need to use two statements to it.

update tableA 
set    varD = '1' 
where  varD = '0' ; 

select varA 
,      varB 
,      varC 
from   tableA 
where  varD = '0' ;

If you're really worried about the two being consistent, wrap them up in a Transaction (assuming you're using InnoDB).

Regards, Phill W.

Options: ReplyQuote


Subject
Written By
Posted
Re: update & select but return the results of the select
July 31, 2014 05: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.