SQL Registring player system by ID
#1

Hello everyone, I would really need help with SQL Lite player id system...

I am not so experienced with SQL's so please can you answer my 2 questions down below?

1st. How can i get biggest id already registred?
2. How can i make it to start from 0 and increase itself after registraton?

Thanks
Reply
#2

1)
pawn Код:
SELECT `ID` FROM `Accounts` ORDER BY `ID` DESC LIMIT 1
`ID` is column in which ID is stored, `Accounts` is table where IDs are stored. Change them to your own.
2) To get auto increse on each new row, make column ID in Table and select AUTO_INCREMENT. It will put number one time higher than last one on each row entry.
Reply
#3

Quote:
Originally Posted by [MG]Dimi
Посмотреть сообщение
1)
pawn Код:
SELECT `ID` FROM `Accounts` ORDER BY `ID` DESC LIMIT 1
`ID` is column in which ID is stored, `Accounts` is table where IDs are stored. Change them to your own.
2) To get auto increse on each new row, make column ID in Table and select AUTO_INCREMENT. It will put number one time higher than last one on each row entry.
Thanks
Reply
#4

pawn Код:
db_query(Database, "CREATE TABLE IF NOT EXISTS `USERS` (`ID` AUTO_INCREMENT,`NAME`, `PASSWORD`, `IP`, `SCORE`, `CASH`, `ADMIN`, `VIP`)");
It always return me nuber 0 when trying to get ids count his way:
pawn Код:
format(Query, sizeof(Query), "SELECT `NAME` FROM `USERS` WHERE `NAME` = '%s' ",name);
                Result = db_query(Database, Query);
                if(db_num_rows(Result))
                {
                    new Field[ 20 ];
                    db_get_field_assoc(Result, "ID", Field, 30);
                    format(Query, sizeof(Query), "**%s has registred making the total of %i players registred.", name, Field);
                    SendClientMessageToAll(0xFFFFFFAA,Query);
                }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)