简体   繁体   中英

Error in where clause of sql update query

Why does the sql query

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

give error whereas

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

or

UPDATE `singleent` SET `pre_timestamp` = CURRENT_TIMESTAMP

runs perfectly?

Edit :

The column type is timestamp and the error was:

Truncated incorrect static value: select listingType

The Error was due to the listingType being of Type varchar and so it needed the value to be in single inverted commas ''

The query

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

is perfect

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM