Reputation: 47
what am I doing wrong with this query:
INSERT INTO 'stats' ('uuid', 'kills', 'deaths', 'games', 'beststreak') VALUES ('5dbef8c9-977a-3ddf-b732-473be6318596', '0', '0', '0', '0')
Here you can see the strutcture of my table:
The error:
[15:11:23 WARN]: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''stats' ('uuid', 'kills', 'deaths', 'games','beststreak') VALUES ('5dbef8c9-977' at line 1
Upvotes: 2
Views: 51
Reputation: 80657
The table and column names should be enclosed either in backticks, or left alone. They shouldn't be enclosed in single or double quotes.
Also, since the last 4 columns are type INT
, you don't need to pass 0
as strings either.
INSERT INTO `stats` (
`uuid`,
`kills`,
`deaths`,
`games`,
`beststreak`
)
VALUES (
'5dbef8c9-977a-3ddf-b732-473be6318596',
0,
0,
0,
0
)
Upvotes: 6
Reputation: 219894
Get rid of the quotes around your table name and column identifiers. Use ticks or nothing.
INSERT INTO stats (uuid, kills, deaths, games, beststreak)
VALUES ('5dbef8c9-977a-3ddf-b732-473be6318596', '0', '0', '0', '0')
or
INSERT INTO `stats` (`uuid`, `kills`, `deaths`, `games`, `beststreak`)
VALUES ('5dbef8c9-977a-3ddf-b732-473be6318596', '0', '0', '0', '0')
Upvotes: 3