[MYSQL] How to retrieve information from multiple rows with one query. - 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] How to retrieve information from multiple rows with one query. (
/showthread.php?tid=502356)
[MYSQL] How to retrieve information from multiple rows with one query. -
AA9 - 23.03.2014
How can i retrieve information from multiple rows in one query? I have following line
pawn Код:
mysql_format(mysql,query,sizeof(query),"SELECT Name FROM pdata WHERE fName = '%s'",cnimi[playerid]);
mysql_tquery(mysql,query,"LoadUser","i",playerid);
How i can select all fNames which are equal to cnimi[playerid] and store them into variables. I'm using R38 plugin.
Re: [MYSQL] How to retrieve information from multiple rows with one query. -
Vince - 23.03.2014
I'd link you to my
thread, but it's currently a bit outdated (no caching).
pawn Код:
for(new i, j = cache_get_row_count(); i < j; i++)
{
new result[MAX_PLAYER_NAME];
cache_get_row(i, 0, result);
printf("result %d: %s", i, result);
}
That would be your basic structure. I don't know what you intend to do with the results, but you could also parse the results into a global array directly.
Re: [MYSQL] How to retrieve information from multiple rows with one query. -
AA9 - 23.03.2014
Okay, but what's then, if one result is at row 1 and other result at row 10 and i only want to use cache_get_field_content for them. I havent undrestand that, how should i get that row number, where i want to select data.
Re: [MYSQL] How to retrieve information from multiple rows with one query. -
Vince - 23.03.2014
I'm afraid I do not quite understand. The cache only stores the results of your query, not the entire table. If there are still unneeded rows in the result then you should think about rewriting the query.
Re: [MYSQL] How to retrieve information from multiple rows with one query. -
AA9 - 23.03.2014
Nevermind, all was okay and worked, thanks.