Problem selecting ID and name from SQLite database
#1

Hello,

I have a problem selecting ID and name from SQLite databalse.

What I was doing is:

pawn Код:
CMD:savedplayers(playerid, params[])
{
    new string[300], DBResult: result;

    result = db_query(serverDB,  "SELECT `ID` AND  `NAME` FROM `PLAYERS`");

    if (db_num_fields(result))
    {
            format(string, sizeof(string), "%s%s", ...);
            ShowPlayerDialog(playerid, 0, DIALOG_STYLE_LIST, "Saved Player List", string, "Close", "");
        db_free_result(result);
        return 1;
    }
    else
    {
        db_free_result(result);
        return 0;
    }
   return 1;
}
So how do I basically show a list of saved players.. I'm lost.
Reply
#2

Change AND to comma.
Reply
#3

Not sure with SQLite, but I am 50% sure that that query is wrong.

"SELECT `ID` AND `NAME` FROM `PLAYERS`" isn't a complete query.

"SELECT `ID` AND `NAME` FROM `PLAYERS` WHERE 1" is a complete query.
Reply
#4

Quote:
Originally Posted by Misiur
Посмотреть сообщение
Change AND to comma.
You sure that just this will make it work? What about a loop? Is it not needed?

Quote:
Originally Posted by Dubya
Посмотреть сообщение
Not sure with SQLite, but I am 50% sure that that query is wrong.

"SELECT `ID` AND `NAME` FROM `PLAYERS`" isn't a complete query.

"SELECT `ID` AND `NAME` FROM `PLAYERS` WHERE 1" is a complete query.
What does that WHERE 1 do? As I know WHERE is a clause that is used to extract only those records that fulfill a specified criterion.
Reply
#5

the one stands for a global where ID and Name are both set to something, it will select them.
Reply
#6

SQLite doesn't require WHERE statement (I think, at least looking at http://www.sqlite.org/lang_select.html ). Currently your query selects all names and id's, but the code processes only first row.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)