MySQL Forums
Forum List  »  Newbie

Re: MySQL UPDATE query
Posted by: Chris Stubben
Date: March 24, 2005 05:21PM

I copied this from the docs... You can't use maps in your subquery if its being updated.

Chris

--

Incorrectly used table in subquery:

Error 1093 (ER_UPDATE_TABLE_USED)
SQLSTATE = HY000
Message = "You can't specify target table 'x'
for update in FROM clause"

This error occurs in cases like this:

UPDATE t1 SET column2 = (SELECT MAX(column1) FROM t1);

It's okay to use a subquery for assignment within an UPDATE statement, since subqueries are legal in UPDATE and DELETE statements as well as in SELECT statements. However, you cannot use the same table, in this case table t1, for both the subquery's FROM clause and the update target.

Options: ReplyQuote


Subject
Written By
Posted
March 19, 2005 05:00PM
Re: MySQL UPDATE query
March 24, 2005 05:21PM


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.