Results 1 to 2 of 2

Thread: update in mysql

  1. #1
    Join Date
    Apr 2004
    Posts
    2

    Talking Unanswered: update in mysql

    friends..

    i have an error using update in my sql

    my query is..


    update table1 set table1.par1=table2.par1
    where table1.id=table2.id

    i got the error that table2 is not defined

    but table1 and table2 are in the same database

    i am using mysql 3.9 version

    can u help?

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    the syntax you want is
    PHP Code:
    update table1
         
    table2
       set table1
    .par1 table2.par1
     where table1
    .id table2.id 
    unfortunately, you must be on 4.0 to use it

    in 3.9 i think your only choice is to do a query, get the table2.par1 value, and use that in a simple update of table1
    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
  •