MYSQL SELECT error
#1

Something strange is going on with MySQL functions. A simple code like this isn't working for some kind of reason.
NB! No result were printed from OnQueryError
Код:
new string[128];
mysql_format(SQL, string, sizeof(string), "SELECT * FROM players WHERE group = %i", selectedGroup[playerid]);
mysql_tquery(SQL, string, "ShowGroupMembers", "i", playerid);
Код:
[DEBUG] mysql_format - connection: 1, len: 128, format: "SELECT * FROM players WHERE group = %i"
 [DEBUG] mysql_tquery - connection: 1, query: "SELECT * FROM players WHERE group = 3", callback: "ShowGroupMembers", format: "i"
[DEBUG] CMySQLQuery::Execute[ShowGroupMembers] - starting query execution
[ERROR] CMySQLQuery::Execute[ShowGroupMembers] - (error #1064) 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 'group = 3' at line 1
 [DEBUG] CMySQLQuery::Execute[ShowGroupMembers] - error will be triggered in OnQueryError
 [DEBUG] Calling callback "OnQueryError"..
Reply
#2

'Group' (as in GROUP BY) is an SQL reserved keyword and as such can't be used as a column name. I recommend adding a prefix or a suffix.
Reply
#3

Like Vince pointed out, group is a reserved keyword. You can surround it in single parentheses to fix this('group').
Reply
#4

I don't know, should i cry or laugh, but thanks! Fixed it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)