ORDER BY ... Some small help.
#1

Hi guys:

pawn Код:
format( szQuery, sizeof szQuery, "SELECT `Name`,`GangKills` FROM `Accounts` ORDER BY (`GangKills`) WHERE `GangID` = '%d' DESC LIMIT 5", GangID );
I have this syntax, and when I use it, this appear in "debug.txt":

Код:
[18:35:27] errorid: 1064 | 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 'WHERE `GangID` = '2' DESC LIMIT 5' at line 1 | resultid: 22 | extraid: -80652920 | callback: OnQueryFinish | query: SELECT `Name`,`GangKills` FROM `Accounts` ORDER BY `GangKills` WHERE `GangID` = '2' DESC LIMIT 5
What is wrong?
Reply
#2

try this
AFIAK WHERE should be used before ORDER BY
pawn Код:
format( szQuery, sizeof szQuery, "SELECT `Name`,`GangKills` FROM `Accounts` WHERE `GangID` = '%d' ORDER BY (`GangKills`) DESC LIMIT 5", GangID );
Reply
#3

This might not help you or fix the problem, but doesnt 'sizeof' be like this? "sizeof(szQuery)" instead of "sizeof szQuery"
Reply
#4

Quote:
Originally Posted by ddnbb
Посмотреть сообщение
This might not help you or fix the problem, but doesnt 'sizeof' be like this? "sizeof(szQuery)" instead of "sizeof szQuery"
it can be used in both ways
Reply
#5

A hint:

pawn Код:
DESC LIMIT 5
Reply
#6

Quote:
Originally Posted by HuSs3n
Посмотреть сообщение
try this
AFIAK WHERE should be used before ORDER BY
pawn Код:
format( szQuery, sizeof szQuery, "SELECT `Name`,`GangKills` FROM `Accounts` WHERE `GangID` = '%d' ORDER BY (`GangKills`) DESC LIMIT 5", GangID );
Thanks, now works

Quote:
Originally Posted by ddnbb
Посмотреть сообщение
This might not help you or fix the problem, but doesnt 'sizeof' be like this? "sizeof(szQuery)" instead of "sizeof szQuery"
It doesn't matter, you can use with "sizeof ( szQuery )" or without ...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)