update a column by subtracting a value

后端 未结 2 1545
不思量自难忘°
不思量自难忘° 2020-12-14 16:50

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` = \'         


        
2条回答
  •  Happy的楠姐
    2020-12-14 17:19

    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.

提交回复
热议问题