visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
315 experts, 1193 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Databases :: MySql :: UPDATE what am I missing?


By: Squibi U.S.A.  Date: 12/09/2004 00:00:00  English  Points: 25 Status: Answered
Quality : Excellent
This SQL will not work under MySQL, but does work under Office DB2 and Oracle.

UPDATE tableA, tableB
SET tableA.usergroupid=8
WHERE
tableB.userid= tableA.userid AND
tableB.country= 'United Kingdom' AND
tableA.usergroupid='5'

What am I missing?


By: VGR Date: 12/09/2004 08:26:00 English  Type : Comment
nothing (except the closing semicolon). This should work.
By: Squibi Date: 12/09/2004 09:55:00 English  Type : Comment
nope doesn't work (even with the closing semicolon)
By: VGR Date: 13/09/2004 05:23:00 English  Type : Comment
first it's rather surprising to see this cohabitate :
tableA.usergroupid='5'
set tableA.usergroupid=8

integer and varchar...
By: VGR Date: 13/09/2004 05:27:00 English  Type : Answer
now, for the cause of the error (BTW, you didn't say WHICH ERROR YOU GOT :/ )

6.4.5 UPDATE Syntax

UPDATE [LOW_PRIORITY] [IGNORE] tbl_name
SET col_name1=expr1 [, col_name2=expr2 ...]
[WHERE where_definition]
[ORDER BY ...]
[LIMIT rows]

or

UPDATE [LOW_PRIORITY] [IGNORE] tbl_name [, tbl_name ...]
SET col_name1=expr1 [, col_name2=expr2 ...]
[WHERE where_definition]

UPDATE updates columns in existing table rows


As you can read here, you need MySql 4.0.4 to perform the query you try to use :
Starting with MySQL Version 4.0.4, you can also perform UPDATE operations that cover multiple tables:

UPDATE items,month SET items.price=month.price
WHERE items.id=month.id;

Note: you can not use ORDER BY or LIMIT with multi-table UPDATE.



For subqueries in MySql you should look at <A HREF="http://www.mysql.com/doc/en/Nutshell_4.1_features.html">http://www.mysql.com/doc/en/Nutshell_4.1_features.html</A>



Do register to be able to answer

EContact
browser fav
page generated in 302.829030 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page