If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > simple update, but big problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-26-04, 06:20
Bumbe Bumbe is offline
Registered User
 
Join Date: Feb 2004
Posts: 3
Question simple update, but big problem

Hi,

I've got a problem with an update statement. It looks like this and I don't get the mistake:

UPDATE tbl1, tbl2
SET tbl1.x = tbl2.z
WHERE tbl1.id = tbl2.id

I already tried this one:

UPDATE tbl1
SET x = tbl2.z
FROM tbl1, tbl2
WHERE tbl1.id = tbl2.id

Any ideas?

THX
Reply With Quote
  #2 (permalink)  
Old 02-26-04, 13:47
tdob tdob is offline
Registered User
 
Join Date: Feb 2004
Posts: 2
post the error message of first update query, syntax is correct, second is bad

Last edited by tdob; 02-26-04 at 13:54.
Reply With Quote
  #3 (permalink)  
Old 02-26-04, 14:26
aus aus is offline
Registered User
 
Join Date: Oct 2003
Location: Denver, Colorado
Posts: 137
Re: simple update, but big problem

You should use the replace syntax for the second query.
http://www.mysql.com/doc/en/REPLACE.html
Reply With Quote
  #4 (permalink)  
Old 02-27-04, 02:24
Bumbe Bumbe is offline
Registered User
 
Join Date: Feb 2004
Posts: 3
The Error Message looks like this:

You have an error in your SQL syntax near ' tbl2 SET tbl1.x = tbl_2.z WHERE t' at line 1

It says already nothing ;-(
Reply With Quote
  #5 (permalink)  
Old 02-27-04, 07:43
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
bumbe, are you on the appropriate version of mysql?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #6 (permalink)  
Old 02-27-04, 07:54
Bumbe Bumbe is offline
Registered User
 
Join Date: Feb 2004
Posts: 3
Quote:
Originally posted by r937
bumbe, are you on the appropriate version of mysql?
Oh, I've checked the version just now. It's 3.23 - That could be the problem ;-)
Reply With Quote
  #7 (permalink)  
Old 02-27-04, 08:10
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
that, indeed, could be the source of all your trouble

multi-table updates aren't allowed!
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On