2

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: http://puu.sh/9F59D/3820d07c83.png

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

2 Answers 2

6

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
)
Sign up to request clarification or add additional context in comments.

Comments

3

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.