how can I let sql/mysql set the next id, that I have no problems with posts at the same time?
Asked
Active
Viewed 814 times
0
-
2Use AUTO_INCREMENT command.... – The Hungry Dictator Nov 01 '13 at 03:13
-
Not quite sure what you're asking for. Do you want to auto-increment a primary key, or get the last insert ID to use in your next insert? – delliottg Nov 01 '13 at 03:15
-
Assuming you are referring to a table insert. Make the column in your table an IDENTITY column. – Dimith Nov 01 '13 at 07:40
1 Answers
0
CREATE TABLE Persons
(
ID int NOT NULL AUTO_INCREMENT,
LastName varchar(255) NOT NULL,
FirstName varchar(255)
)
Auto_Increment
can be used as ID as there wont any duplicate value.
When insert value for the table :
INSERT INTO Persons (FirstName,LastName)
VALUES ('Hello','World')
The table will look like this.
ID | FirstName | LastName
1 | Hello | World

chinna_82
- 6,353
- 17
- 79
- 134