There is a common issue which is usually faced by almost every newbie web developer or database administrator. When you insert records in your table of database after deleting all or some records from that table, if AUTO_INCREMENT property was set on your ID column or any other column, when you insert new records in that table it starts generating ID after the last ID generated by AUTO_INCREMENT in table, the following SQL query can reset the AUTO_INCREMENT from beginning or any number you want. 🙂

SQL Query


You can also reset it from the MySQL => Operations => Table Options. Just change AUTO_INCREMENT to 1.


Facebook Official Page: All PHP Tricks

Twitter Official Page: All PHP Tricks

Article By
Javed Ur Rehman is a passionate blogger and web developer, he loves to share web development tutorials and blogging tips. He usually writes about HTML, CSS, JavaScript, Jquery, Ajax, PHP and MySQL.
  1. Hi Mr. Javed,

    recently I reached your web site. you are explained all in detail in a simple way.
    my name is George Fernandez old developer since 1986. I would like to shift my platform from visual FoxPro to PHP, Mysql, HTML, CSS, Bootstrap, Jquery, Javascript, Ajax.
    I have some doubt regards above mentioned languages. so can help to solve my doubts.
    Please give me your email and WhatsApp.
    I am waiting for your reply.

  2. Very Nice tutorials brother, Thanks… Keep it up…
    Do you have youtube videos please display links on the tutorial…

Leave a Reply

Your email address will not be published. Required fields are marked *