How to update table from same table?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SwigriD
    New Member
    • Jul 2010
    • 4

    #1

    How to update table from same table?

    Hello all,

    I'm not sure how to update table form same table. I've got this code so far, which doesn't work. :-/

    Code:
    UPDATE WIP
    SET Status = WIP2.Status
    FROM WorkInProgress AS WIP
    JOIN WorkInProgress AS WIP2
    ON WIP.LOAMID = WIP2.LOAMID
    WHERE WIP.wipDate = LastDate
    AND WIP2.wipDate = DateBeforeLastOne
    AND WIP.Status IS NULL;
    Any ideas on that one?
    Thank you :o)
  • SwigriD
    New Member
    • Jul 2010
    • 4

    #2
    hello again,

    I modified by this example and it's working fine now :)

    Code:
    UPDATE M_Emp as A
    INNER JOIN M_Emp as B ON A.Emp_ID = B.Emp_ID
    SET A.Salary = B.Salary*1.1

    Comment

    • nico5038
      Recognized Expert Specialist
      • Nov 2006
      • 3080

      #3
      Even easier:

      Code:
      UPDATE M_Emp as A SET Salary = Salary*1.1
      But puzzled why you change a status field....

      Nic;o)

      Comment

      Working...