Simple Update Query using select statement....but why isn't it working??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • themightyrhino
    New Member
    • Oct 2008
    • 4

    Simple Update Query using select statement....but why isn't it working??

    I'm writing a process to perform multiple updates on a main table from information stored in different component reports. As you can see from the below, I'm using a select query to base the update on.

    UPDATE DELTA_OD001_TMP TD
    SET (ORDER_DATE,VET _NO, VET_SCORE, VET_DECISION, PARTNER, ORANGE_ID)
    =(SELECT ORDER_DATE, VET_NO, VET_SCORE, VET_DECISION, PARTNER, ORANGE_ID
    FROM IMPORT_OD001_OR DERS IO
    WHERE TD.ORDER_NO = IO.ORDER_NO);

    The problem I'm getting is that the query seems to be updating all 683748 records of the delta_od001_tmp table. However when I run the select statement on its own, the results show 8779 records so I know that there should only be 8779 records to update. The order number will appear more than once in the delta_od001_tmp table but surely that would still be brought back as part of the 8779 records and the update applied to this data set regardles, and not mean it updates all 6833748?

    Any quick help would be much appreciated!
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    The update statement itself does not have a where clause so it will update every record.

    Comment

    Working...