i have a table with some rows.
idClient, name, adress,country,...
i want to know how i can do an insert into this table with auto increment my idClient in my sql request..? Thx.
edit: i want do a request like this
insert into Client values((select max(idClient),...)
Define the id column as
AUTO_INCREMENT
, then skip the assignment altogether:Then when you insert into the table, exclude the auto-incrementing primary key column from your insert:
The new value of idClient will be generated.
This is the only way to do this safely if there are multiple instances of an application inserting rows at once. Using the MAX(idClient) method you describe will not work, because it's subject to race conditions.