Hello. I apologize, I do not know how to express myself correctly, therefore I describe in simple words what I want.

Suppose there is a format table in the database.

[число ID] [тСкст Имя] [тСкст Ѐамилия] 

I need to increase by 1 when adding a new record

That is, for example, entries in the table

 [id = 0] [Имя = АлСксСй] [Ѐамилия = НСназванный] [id = 1] [Имя = Π•Π²Π³Π΅Π½ΠΈΠΉ] [Ѐамилия = Названный] [id = 2] [Имя = Π€Ρ‘Π΄ΠΎΡ€] [Ѐамилия = НСизвСстный] 

And I want to add a new entry to the Id field to add the number +1 from the previous entry

How to make a request to add a record shorter?

respectfully

    1 answer 1

    When creating the table, it was just necessary to use the AUTOINCREMENT specifier. In this case, the id will be generated automatically.

     CREATE TABLE some_table ( id MEDIUMINT NOT NULL AUTO_INCREMENT, fisrt_name CHAR(30) NOT NULL, last_name CHAR(30) NOT NULL, PRIMARY KEY (id) ); 

    In order to add an entry to the table formed in the query above (it is similar to the one in the question), you need to run this query:

     INSERT INTO some_table (first_name, last_name) VALUES('Имя','Ѐамилия'); 

    In this case, the id of the new record will be generated by the DBMS itself and equal to the id of the previous record +1

    • thank you very much! - Grigory Ponomarev