Help about mysql function
#5

Quote:
Originally Posted by jasperschellekens
Посмотреть сообщение
SQL has nice options called autoincrement and primary key.
You can set these as fieldname ID for example.
Take a look at this query to create a table:

Код:
CREATE TABLE Persons (
    ID int NOT NULL AUTO_INCREMENT,
    LastName varchar(255) NOT NULL,
    FirstName varchar(255),
    Age int,
    PRIMARY KEY (ID)
);
The field ID in the table Persons was created as auto_increment and "PRIMARY KEY (ID)" makes this field a primary key.
This feature allows you to have an unique ID for each row in the database and you are not required to count it scriptwise.
For example when there are 4 rows in the table with id 1,2,3 and 4, SQL automatically created ID 5 at the next row and 6 for the one after that and go on..

All you have to do in your query is putt "null" as ID and SQL will do the rest for you:

PHP код:
format(Querysizeof(Query), "INSERT INTO `Persons` (`ID`, `LastName`, `FirstName`, `Age`) VALUES(NULL,'%s', '%s', '%d')"LastNameVar[playerid], FirstNameVar[playerid], AgeVar[playerid]); 
Thank you.
Reply


Messages In This Thread
Help about mysql function - by masuzaron - 22.04.2018, 10:46
Re: Help about mysql function - by TitoRayne - 22.04.2018, 10:50
Re: Help about mysql function - by masuzaron - 22.04.2018, 10:56
Re: Help about mysql function - by jasperschellekens - 22.04.2018, 11:57
Re: Help about mysql function - by masuzaron - 22.04.2018, 14:02

Forum Jump:


Users browsing this thread: 1 Guest(s)