Skip to content
Advertisement

Error in sql syntax value ? but it’s showing the value?

the title isn’t very specific but I don’t know how to make it better. I’ve got this error in my sql telling me something is wrong but I don’t understand why it’s wrong, currently using mysql 8.0.24. If you wonder why it looks strange it’s because I use it in lua

Sql:

local q = [[SELECT id, hex_id, steam_id, community_id, name, ip, rank FROM users WHERE hex_id = @id;]]
local v = {["id"] = hexId}

Error:

An error happens for query "SELECT id, hex_id, steam_id, community_id, name, ip, rank FROM users WHERE hex_id = ?; : ["steam:*****"]": ER_PARSE_ERROR: 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 'FROM users WHERE hex_id = 'steam:*****'' at line 1

Advertisement

Answer

RANK is a keyword in MySQL 8. You need to enclose it inside backticks:

SELECT id, hex_id, steam_id, community_id, name, ip, `rank` FROM users ...
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement