在mysql php中将Date列设置为当前时间

时间:2022-10-29 08:07:00

I am trying to set the date column to the current time stamp but for some reason I keep getting a syntax error.

我试图将日期列设置为当前时间戳,但由于某种原因,我不断收到语法错误。

$sql = "UPDATE testGraph
    SET date = CURRENT_TIMESTAMP
    SET State = ".$state1."
    WHERE Serial = ".$serial1."
   ";

2 个解决方案

#1


1  

Only one SET keyword is allowed in an UPDATE statement.

UPDATE语句中只允许一个SET关键字。

Replace the second SET keyword with a comma.

用逗号替换第二个SET关键字。

UPDATE mytable 
   SET mycol1  = expr1
     , mycol2  = expr2
--   ^
 WHERE ... 

#2


0  

In a update query only one SET attribute is used Syntax

在更新查询中,只使用一个SET属性语法

UPDATE table_name SET column1=value1,column2=value2,... WHERE some_column=some_value;

UPDATE table_name SET column1 = value1,column2 = value2,... WHERE some_column = some_value;

#1


1  

Only one SET keyword is allowed in an UPDATE statement.

UPDATE语句中只允许一个SET关键字。

Replace the second SET keyword with a comma.

用逗号替换第二个SET关键字。

UPDATE mytable 
   SET mycol1  = expr1
     , mycol2  = expr2
--   ^
 WHERE ... 

#2


0  

In a update query only one SET attribute is used Syntax

在更新查询中,只使用一个SET属性语法

UPDATE table_name SET column1=value1,column2=value2,... WHERE some_column=some_value;

UPDATE table_name SET column1 = value1,column2 = value2,... WHERE some_column = some_value;