Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2003
    Posts
    14

    Unanswered: problem updating one table with values from multiple tables

    Hi all-

    I'm having trouble with a query that tries to update one table with values from a few other joined tables. the query looks something like this:

    update table1 t1
    set t1.value1= (t2.value1 + t3.value1)
    t1.value1= (t2.value1 / t3.value2)
    from table2 t2, table3 t3
    where t2.foo=t3.foo and t1.foo=t2.foo


    i keep getting an error:
    ORA-00933: SQL command not properly ended

    for the "from" line.

    any clues?
    Last edited by earlbradley; 01-02-04 at 20:13.

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    Your syntax is not valid; which is why you are getting an error message.

  3. #3
    Join Date
    Dec 2003
    Posts
    14
    Originally posted by anacedent
    Your syntax is not valid; which is why you are getting an error message.
    what is the proper syntax for such a query in Oracle? (it seems to work this way on postgresql)
    Last edited by earlbradley; 01-02-04 at 20:10.

  4. #4
    Join Date
    Dec 2003
    Posts
    14

    Re: problem updating one table with values from multiple tables

    Originally posted by earlbradley
    update table1 t1
    set t1.value1= (t2.value1 + t3.value1)
    t1.value1= (t2.value1 / t3.value2)
    from table2 t2, table3 t3
    where t2.foo=t3.foo and t1.foo=t2.foo
    so this is what worked (finally!)

    update table1
    set (t1)=(select (t2.value1 + t3.value1) from table2 t2, table3 t3 where t2.foo = t3.foo),
    set (t2)=(select (t2.value1 / t3.value2) from table2 t2, table3 t3 where t2.foo = t3.foo)

Posting Permissions

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