Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2004
    Posts
    3

    Question Unanswered: 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

  2. #2
    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 14:54.

  3. #3
    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

  4. #4
    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 ;-(

  5. #5
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    bumbe, are you on the appropriate version of mysql?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  6. #6
    Join Date
    Feb 2004
    Posts
    3
    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 ;-)

  7. #7
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    that, indeed, could be the source of all your trouble

    multi-table updates aren't allowed!
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •