tags:

views:

65

answers:

3

Hi, how can I update 2 columns at a time?

I tried the following statement, which doesn't work:

UPDATE exercises
SET times_answered = times_answered + 1
AND av_answeringTime = av_answeringTime + ( (av_answeringTime / (times_answered) ) + ?) * (times_answered + 1)
WHERE name = ?

Thanks.

+3  A: 

Use a comma instead of your "AND":

UPDATE exercises
SET times_answered = times_answered + 1,
    av_answeringTime = av_answeringTime + ( (av_answeringTime / (times_answered) ) + ?) * (times_answered + 1)
WHERE name = ?
Chad Birch
+2  A: 

Try something like this...

UPDATE exercises
SET times_answered = times_answered + 1,
av_answeringTime = av_answeringTime + ( (av_answeringTime / (times_answered) ) + ?) * (times_answered + 1)
WHERE name = ?
Jhonny D. Cano -Leftware-
+2  A: 

The SQL UPDATE syntax is:

UPDATE table SET
  column1 = value1,
  column2 = value2
WHERE condition

Instead of the AND you need a comma

Ayman