Take the 2-minute tour ×

I got some problems with finding a bug in php/mysql application, and I wonder if I can do something like this: UPDATE table SET userid='2' WHERE userid='1' - > Can I update something I state in WHERE?

share|improve this question
add comment

2 Answers

up vote 8 down vote accepted

Absolutely. You can even reference the current value of the column in the set:

UPDATE table SET x = x + 5 WHERE x < 3

share|improve this answer
add comment

I see no problem, and you can do a lot more...

share|improve this answer
add comment

Your Answer


