MySQL Query Question

Associate
Joined
27 Jun 2008
Posts
1,538
My MySQL skills are a little rusty and I trying to figure out how to make a statement that will add a value to an existing field value in the table. I have a table that contains 3 fields id, name and score. For example:-

id name score
1 John 5
2 Alex 2
3 Sarah 7

It's crude I know. :)

So I add a new entry (Stacey, 4) and that gets a assigned an ID and added. Now I want to amend an existing score, say Alex's by +3. Can I make a statement to add the scores together if it finds an ID that aleady exists in the field?
 
I'm sure I'm going to need to use an IF statement although I'm not sure how to go about writing the condition to check if the user ID already exists in the specified field.
 
Back
Top Bottom