A better way of doing this query?
#1

Is there a better way of doing this query?

pawn Код:
mysql_format(Connection, Query, sizeof Query, "SELECT `name` FROM `characters` WHERE `id` = %d LIMIT 1", MasterAccounts[playerid][maCharacter][0]);
mysql_function_query(Connection, Query, true, "SelectCharacterNames", "d", playerid);

mysql_format(Connection, Query, sizeof Query, "SELECT `name` FROM `characters` WHERE `id` = %d LIMIT 1", MasterAccounts[playerid][maCharacter][1]);
mysql_function_query(Connection, Query, true, "SelectCharacterNames", "d", playerid);

mysql_format(Connection, Query, sizeof Query, "SELECT `name` FROM `characters` WHERE `id` = %d LIMIT 1", MasterAccounts[playerid][maCharacter][2]);
mysql_function_query(Connection, Query, true, "SelectCharacterNames", "d", playerid);

mysql_format(Connection, Query, sizeof Query, "SELECT `name` FROM `characters` WHERE `id` = %d LIMIT 1", MasterAccounts[playerid][maCharacter][3]);
mysql_function_query(Connection, Query, true, "SelectCharacterNames", "d", playerid);
What I am doing is selecting the character name for four slots where the master account id matches.
Reply
#2

pawn Код:
mysql_format(Connection, Query, sizeof Query, "SELECT `name` FROM `characters` WHERE `id` IN (%d, %d, %d, %d)", MasterAccounts[playerid][maCharacter][0], MasterAccounts[playerid][maCharacter][1], MasterAccounts[playerid][maCharacter][2], MasterAccounts[playerid][maCharacter][3]);
mysql_function_query(Connection, Query, true, "SelectCharacterNames", "d", playerid);
Then loop through rows and compare 'id' with MasterAccounts[playerid][maCharacter][x] to correlate slot with row.
Reply
#3

Quote:
Originally Posted by Misiur
Посмотреть сообщение
pawn Код:
mysql_format(Connection, Query, sizeof Query, "SELECT `name` FROM `characters` WHERE `id` IN (%d, %d, %d, %d)", MasterAccounts[playerid][maCharacter][0], MasterAccounts[playerid][maCharacter][1], MasterAccounts[playerid][maCharacter][2], MasterAccounts[playerid][maCharacter][3]);
mysql_function_query(Connection, Query, true, "SelectCharacterNames", "d", playerid);
Then loop through rows and compare 'id' with MasterAccounts[playerid][maCharacter][x] to correlate slot with row.
Cheers.
Reply
#4

I need a little help with the second part of what Misiur said, I have this so fair:
pawn Код:
public SelectCharacterNames(playerid)
{
    new
        Rows,
        Fields;

    cache_get_data(Rows, Fields);

    while(Rows)
    {

    }
    return 1;
}
I just don't know what to do after that.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)