SA-MP Forums Archive
MySQL 2.1.1 [Multiple Rows in 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 2.1.1 [Multiple Rows in one Query] (/showthread.php?tid=497479)



MySQL 2.1.1 [Multiple Rows in one Query] - Dubya - 27.02.2014

I have a question, if I am trying to obtain information from multiple rows in one query,

e.g:
Код:
SELECT `Username`,`ID` FROM `characters` WHERE `OwnerID`='1'
Can I get information on each of the rows that get a result? I really don't want to have to switch MySQL plugins, but I have never tried this before. If someone has found a way to do this, please share your tip with me?

- https://sampforum.blast.hk/showthread.php?tid=122983

Edit: Nevermind, answer not solved


Re: MySQL 2.1.1 [Multiple Rows in one Query] - Dubya - 27.02.2014

Edited again.. Answer not solved


Re: MySQL 2.1.1 [Multiple Rows in one Query] - Dubya - 27.02.2014

bump


Re: MySQL 2.1.1 [Multiple Rows in one Query] - Misiur - 27.02.2014

You already are fetching multiple rows. What's your current pawn code?


Re: MySQL 2.1.1 [Multiple Rows in one Query] - SKAzini - 27.02.2014

Are you looking for this?

pawn Код:
new string[500];
format(string, sizeof(string), "SELECT * FROM users WHERE Name = '%s'", UserStats[playerid][Name]);
mysql_query(string);
mysql_store_result();
                   
while (mysql_retrieve_row())
{
    mysql_fetch_field_row(string, "Password");
    format(UserStats[playerid][Password], 129, "%s", string);

    mysql_fetch_field_row(string, "Admin");
    UserStats[playerid][Admin] = strval(string);
                       
    mysql_fetch_field_row(string, "Kills");
    UserStats[playerid][Kills] = strval(string);
                       
    mysql_fetch_field_row(string, "Deaths");
    UserStats[playerid][Deaths] = strval(string);
}
mysql_free_result();
If this is what you're searching for, take a while to look through the code I gave you, eventually you will understand how it works.


Re: MySQL 2.1.1 [Multiple Rows in one Query] - Dubya - 27.02.2014

Quote:
Originally Posted by SKAzini
Посмотреть сообщение
Are you looking for this?

pawn Код:
new string[500];
format(string, sizeof(string), "SELECT * FROM users WHERE Name = '%s'", UserStats[playerid][Name]);
mysql_query(string);
mysql_store_result();
                   
while (mysql_retrieve_row())
{
    mysql_fetch_field_row(string, "Password");
    format(UserStats[playerid][Password], 129, "%s", string);

    mysql_fetch_field_row(string, "Admin");
    UserStats[playerid][Admin] = strval(string);
                       
    mysql_fetch_field_row(string, "Kills");
    UserStats[playerid][Kills] = strval(string);
                       
    mysql_fetch_field_row(string, "Deaths");
    UserStats[playerid][Deaths] = strval(string);
}
mysql_free_result();
If this is what you're searching for, take a while to look through the code I gave you, eventually you will understand how it works.
Thanks, I can work with BlueGz r6.