sql update query的where子句出错

时间:2016-03-23 07:32:03

标签: mysql sql timestamp where clause

为什么sql查询

UPDATE `singleent` SET `pre_timestamp` = CURRENT_TIMESTAMP WHERE listingType = 1

给出错误,而

UPDATE `singleent` SET `pre_timestamp` = CURRENT_TIMESTAMP WHERE 1

UPDATE `singleent` SET `pre_timestamp` = CURRENT_TIMESTAMP

完美运行?

修改

列类型为时间戳,错误为:

  

截断不正确的静态值:选择listingType

1 个答案:

答案 0 :(得分:0)

错误是由于listingType属于Type varchar所以它需要将值放在单个引号中''

查询

UPDATE `singleent` 
   SET `pre_timestamp` = CURRENT_TIMESTAMP 
WHERE listingType = '1' 

很完美