Saturday, 23 July 2016

php - MySQL said: Documentation (#1064) - You have an error in your SQL syntax;



I am trying to create a table in my mysql database and I keep getting this error. Please help, code is below:



CREATE TABLE 'Test'.'Sensor' (
'id' INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
'time' TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
'value' VARCHAR( 10 ) NOT NULL,
)



The Error is:



MySQL said: Documentation




#1064 - You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near ''Test'.'Sensor' ( 'id' INT NOT NULL AUTO_INCREMENT PRIMARY KEY,

'time' TIMES' at line 1



Answer



Remove the single quotes and try like this:-



CREATE TABLE Test.Sensor ( 
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
value VARCHAR( 10 ) NOT NULL
);


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...