update a column by subtracting a value
I'm trying to come up with a MySQL query that will update points
... Can I do something like this?
UPDATE `a75ting`.`username` SET `points` = '`points` - 5'
UPDATE a75ting.username
SET points = points - 5
by putting the single quotes around the "points -5", you converted that expression into a plaintext string. Leaving it without the quotes lets MySQL see you're referring to a field (points) and subtracting 5 from its current value.
Run this query to find out the difference:
SELECT '`points` - 5' AS string, `points` - 5 AS expression
FROM a75ting.username
精彩评论