MySQL Forums
Forum List  »  Oracle

Re: update with select in MYSQL
Posted by: Roland Bouman
Date: January 27, 2006 12:44PM

Last line from this page on the UPDATE syntax (see: http://dev.mysql.com/doc/refman/5.0/en/update.html) in MySQL:

"
Currently, you cannot update a table and select from the same table in a subquery.
"

(I know of this only because I ran into trouble some time, and it was pointed out to me by Felix Geerinckx. Man, I wish this limitation was lifted)

I assume that in this case, the subquery is scalar. If so, you can do:

select @b_data:=B_DATA
from SYS_CONFIG_DATA
where VID = 430
and SERVER_ID = 42
;

and immediately after that:

Update SYS_CONFIG_DATA
set B_DATA =@b_data
where VID = 430
and SERVER_ID = 924

(you should lock the table for updates and deletes or perform it all inside a single transaction to avoid the data from being changed in between your statements)

Options: ReplyQuote


Subject
Views
Written By
Posted
195431
January 22, 2006 09:51AM
72265
January 25, 2006 07:42AM
65174
January 25, 2006 09:19AM
Re: update with select in MYSQL
65211
January 27, 2006 12:44PM
46780
September 27, 2006 09:44PM
33127
May 13, 2009 02:51PM


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.