Search code examples
mysqlsqldatabasenetbeansembedded-database

What syntax error does this sql command have?


I am trying to create a table in java embedded database ( with netbeans). I'm getting an error when executing the table creation command.
This is the error:

https://i.sstatic.net/PEUVz.jpg


Solution

  • The problem is the hyphen, as pointed out in the comments. So replace it with an underscore as suggested, or simply use backticks to escape it. So, in the create table declaration:

    `first-one`
    

    This is likely because the SQL server is interpreting the - as a mathematical operator 'minus'. You will find this to be the case with all reserved words and operators which you want to use literally. More complete information on this topic can be found here: http://dev.mysql.com/doc/refman/5.7/en/keywords.html