22.04.2018, 14:02
Quote:
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) ); 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 код:
|