开发者

Trying to add 1 to current field value with MySQL, but can't figure out what's wrong with my syntax

开发者 https://www.devze.com 2023-01-27 17:57 出处:网络
I\'m hoping someone can spot my mistak开发者_如何学Ce in this MySQL query. UPDATE \'databasename\'.\'tablename\'

I'm hoping someone can spot my mistak开发者_如何学Ce in this MySQL query.

UPDATE 'databasename'.'tablename' 
   SET fieldB = fieldB + 1 
 WHERE fieldA = '2';

I'm basically trying to add 1 to the current value of fieldB where fieldA is i.e 2.


Single-quotes are for strings.

UPDATE `databasename`.`tablename` 
SET fieldB = fieldB + 1 
WHERE fieldA = '2';

You can use backticks around the database and tablenames; they aren't strictly necessary though.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号