Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What syntax error does this sql command have? [closed]

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

like image 329
Aliya Avatar asked Aug 12 '26 04:08

Aliya


1 Answers

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

like image 56
Redbeard011010 Avatar answered Aug 13 '26 19:08

Redbeard011010



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!