SA-MP Forums Archive
MYSQL SELECT error - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MYSQL SELECT error (/showthread.php?tid=584816)



MYSQL SELECT error - AA9 - 08.08.2015

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"..



Re: MYSQL SELECT error - Vince - 08.08.2015

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


Re: MYSQL SELECT error - rymax99 - 08.08.2015

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


Re: MYSQL SELECT error - AA9 - 08.08.2015

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