user7466895
user7466895

Reputation: 319

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?

Upvotes: 5

Views: 16320

Answers (1)

jonroethke
jonroethke

Reputation: 1162

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');

Upvotes: 7

Related Questions