Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL INSERT INTO - "(" is not valid at this position

I'm trying to insert data in to my 'command' table where 'trigger' and 'desc' are not null varchar(255) and there is an int 'id' primary key set to auto increment.

MySQL workbench is throwing an error for the open parentheses after 'command':

"(" is not valid at this position for this server version, expecting: VALUE, SELECT, SET, VALUES, WITH

For any insert query I attempt e.g:

INSERT INTO command('trigger','desc') VALUES("value","value");

This is likely a really simple error on my part but I can't seem to spot what is wrong here, any ideas?

like image 841
user7466895 Avatar asked Jan 19 '19 02:01

user7466895


1 Answers

Desc & trigger are reserved words, so they can't be used as column names unless you use backticks. See this post for further explanation.

Once this is resolved, the SQL query is also incorrectly formatted as the column names should not be surrounded by quotes.

Use the following as a guide:

INSERT INTO command (`trigger`, `desc`) VALUES ('value', 'value');
like image 133
jonroethke Avatar answered Nov 02 '22 23:11

jonroethke