as the thread name

$query2= "alter table employee_leave_quota auto_increment= LAST_INSERT_ID()";

That is my query to reset auto_increment in my table, but it show error..

anybody know how to do it?

so its not possible to recover the primary key that is already deleted?

in any database, if primary key is once deleted, it can never be used again. To reset the primary key, you have to TRUNCATE your table which will result in loss of all the data. So i will not suggest you to reset the table

usually you do not delete data from a table,
usually the data is marked deleted, in a table column(type =date or timestamp) for that purpose, and the "deleted" item is excluded from other reports
this is to ensure trace-ability,
deleted items can screw up later work

oh.. ok thanks..

in any database, if primary key is once deleted, it can never be used again. To reset the primary key, you have to TRUNCATE your table

NOT TRUE. The query above works fine, just the last_insert_id won't. Even in MSSQL you can reset an identity column.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.