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

11,567

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');
Share:
11,567
user7466895
Author by

user7466895

Updated on June 24, 2022

Comments

  • user7466895
    user7466895 almost 2 years

    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?

  • user7466895
    user7466895 over 5 years
    That worked, cheers! I also had to use backticks on trigger for the query to work, is that a reserved word too?
  • jonroethke
    jonroethke over 5 years
    Ah yeah, good catch. Probably a good idea not to use reserved words as col names