MySQL 2.1.1 [Multiple Rows in one Query]
#1

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

Edited again.. Answer not solved
Reply
#3

bump
Reply
#4

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)