-2

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

Shyam Agarwal
  • 119
  • 1
  • 2
  • 10

1 Answers1

0

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

Shyam Agarwal
  • 119
  • 1
  • 2
  • 10