[MYSQL] How to retrieve information from multiple rows with one query.
#1

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.
Reply
#2

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.
Reply
#3

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.
pawn Код:
(row, const field_name[]
Reply
#4

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.
Reply
#5

Nevermind, all was okay and worked, thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)