How do I update one column in multiple records using a subquery on the same table?

I want to update a column by adding a constant to the current value of the column for multiple records.  I tried:

UPDATE fuel_surcharges as X
    SET surchargepercent =
       (SELECT (surchargepercent + 6)
            from fuel_surcharges
           WHERE fuelsurchrecid = X.fuelsurcrecid)

I'm not sure I'm using the correct technique by trying to do this with a subquery.  Any help would be greatly appreciated.
dneill8Asked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
please try this much shorted syntax:
UPDATE fuel_surcharges
    SET surchargepercent = surchargepercent + 6

Open in new window

0
 
matty1stopCommented:
How about this

UPDATE fuel_surcharges
    SET surchargepercent = surchargepercent + 6
0
 
mastooCommented:
UPDATE fuel_surcharges
    SET surchargepercent = surchargepercent + 6
    Where    add some condition here to limit what records it happens on

0
 
dneill8Author Commented:
I guess I was trying to make it too complicated.  Angel gets it as he was the first.  Thanks for the fast reply.
0
All Courses

From novice to tech pro — start learning today.