Can you do this query/is there a better way of doing it? - 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: Can you do this query/is there a better way of doing it? (
/showthread.php?tid=633351)
Can you do this query/is there a better way of doing it? -
Dokins - 29.04.2017
pawn Код:
format(query, sizeof(query), "SELECT `CSlot1`, `CSlot2`, `CSlot3`, `FSlot` FROM `accounts` WHERE id = %d, id = %d, id = %d, id =%d", AccID[playerid][0], AccID[playerid][1], AccID[playerid][2], AccID[playerid][3]);
mysql_tquery(dbHandle, query, "GetMASlot", "si",intext, playerid);
Re: Can you do this query/is there a better way of doing it? -
coool - 29.04.2017
i don't know what is your main purpose but it won't work with comma use an " AND "...
Код:
WHERE id=%d AND id=%d
Re: Can you do this query/is there a better way of doing it? -
Vince - 29.04.2017
Adding a number to a column name is almost never a good idea. It usually signals poor database design.
If you want to select rows based on values in a list then you should the IN operator, e.g.
PHP код:
SELECT * FROM table WHERE id IN(1, 3, 5, 7)
Or even
PHP код:
SELECT * FROM table WHERE someId IN(SELECT id FROM anotherTable WHERE foo = bar)
Re: Can you do this query/is there a better way of doing it? -
Dokins - 29.04.2017
I don't really see how that can be the case could you explain? I use it for more efficient data retrieval, i.e
pawn Код:
format(string, sizeof(string), "CSlot%d", slot);
Never heard of the IN operator, thank you very much.