Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004

    Unanswered: update query statement ?


    The below query has some problem :

    update (table1 inner join table2 on table1.sno = table2.sno) inner join table3 on table2.sno1 = table3.sno set table1.sno1 = 2

    SQL Server 2000, throws a syntax error :
    'Incorrect syntax near keyword '(' ' on executing the above statement.

    Please advice 'what is the error in the above statement ? '


  2. #2
    Join Date
    Feb 2004
    The update doesn't take the first ( , it needs a tablename or view.

    try something like below:

    update table1
    set myint1 = t2.myref
    from table1 t1
    inner join table2 t2 on (t1.myref = t2.myref)
    where t2.myval = somevalue

  3. #3
    Join Date
    Jul 2003
    San Antonio, TX
    It just needs proper order of clauses, and preferably table aliases since there are JOINS:

    update t1 set t1.sno1 = 2
    from table1 t1
    inner join table2 t2 on t1.sno = t2.sno
    inner join table3 t3 on t2.sno1 = t3.sno
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

Posting Permissions

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