Results 1 to 3 of 3

Thread: Update Query

  1. #1
    Join Date
    Sep 2011
    Posts
    85

    Question Unanswered: DB2 Update multiple rows with Subquery

    Hi All

    I have a update query to update name of a buyer. There are 13 places this change need to take place.
    Im posting my Query. But this updates more than 13 records. But the subquery I'm using to fetch the records gives me correct 13 records

    Please Help

    I'm using DB2 10.5 fixpack 4

    UPDATE ORDERPARTIES
    SET BUYER = 'Cyber Power Inc'
    WHERE BUYER IN (select OP.BUYER
    from ORDERATTRIBUTE OA, ORDERPARTIES OP
    where OA.ORDERID = OP.ORDERID
    and OA.PONUMBER in ('5723573','5723569','5723568','5723377','5723376' ,'5722806','5722804','5722798','5722487','5722485' ,'5722420','5722419','5722418')
    and OP.BUYERORGID = 5717989018145575
    and OP.SELLERORGID = 5717989018147286)
    Last edited by ai_zaviour; 11-14-14 at 06:43.

  2. #2
    Join Date
    Nov 2014
    Posts
    2
    Use this code...

    Code:
    SELECT * FROM ORDERPARTIES
     WHERE BUYER IN (select OP.BUYER
     from ORDERATTRIBUTE OA, ORDERPARTIES OP
     where OA.ORDERID = OP.ORDERID
     and OA.PONUMBER in ('5723573','5723569','5723568','5723377','5723376' ,'5722806','5722804','5722798','5722487','5722485' ,'5722420','5722419','5722418')
     and OP.BUYERORGID = 5717989018145575
     and OP.SELLERORGID = 5717989018147286)
    ...to see what is being affected by your UPDATE statement. The simple fact is that you must have multiple ORDERPARTIES rows for one or more of your BUYER values.

  3. #3
    Join Date
    Sep 2011
    Posts
    85
    Thanx for this (Y)

Posting Permissions

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