Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6349607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:38:59+00:00 2026-05-24T21:38:59+00:00

I have an invoices table which stores a single record for each invoice, with

  • 0

I have an invoices table which stores a single record for each invoice, with the id column (int AUTO_INCREMENT) being the primary key, but also the invoice reference number.

Now, unfortunately I’ve had to manual migrate some invoices generated on an old system which have a five digit id, instead of a four digit one which the current system uses.

However, even when I reset the AUTO_INCREMENT through PhpMyAdmin (Table Operations) back to the next four digit id, it still inserts a five digit one being the higher id currently in the table plus one.

From searching around, it would seem that I actually need to change the insert_id as well as the AUTO_INCREMENT ? I’ve tried to execute ALTER TABLE invoices SET insert_id=8125 as well as ALTER TABLE invoices insert_id=8125 but neither of these commands seem to be valid.

Can anyone explain the correct way that I can reset the AUTO_INCREMENT so that it will insert records with id’s 8125 onwards, and then when it gets to 10962 it will skip over the four records I’ve manually added and continue sequential id’s from 10966 onwards. If it won’t skip over 10962 – 10966 then this doesn’t really matter, as the company doesn’t generate that many invoices each year so this will occur in a subsequent year hence not causing a problem hopefully.

I would really appreciate any help with this sticky situation I’ve found myself in! Many Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T21:39:01+00:00Added an answer on May 24, 2026 at 9:39 pm

    First thing I’ll suggest is to ditch PHPMyAdmin because it’s one of the worst “applications” ever made to be used to work with MySQL. Get a proper GUI. My favourite is SQLYog.

    Now on to the problem. Never, ever tamper with the primary key, don’t try to “reset” it as you said or to update columns that have an integer generated by the database. As for why, the topic is broad and can be discussed in another question, just never, ever touch the primary key once you’ve set it up.

    Second thing is that someone was deleting records of invoices hence the autoincrement is now at 10k+ rather than at 8k+. It’s not a bad thing, but if you need sequential values for your invoices (such as there can’t be a gap between invoices 1 and 5) then use an extra field called sequence_id or invoice_ref and use triggers to calculate that number. Don’t rely on auto_increment feature that it’ll reuse numbers that have been lost trough DELETE operation.

    Alternatively, what you can do is export the database you’ve been using, find the CREATE TABLE definition for the invoices table, and find the line where it says “AUTO_INCREMENT = [some number]” and delete that statement. Import into your new database and the auto_increment will continue from the latest invoice. You could do the same by using ALTER TABLE however it’s safer to re-import.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table which has a list of invoices and their details: class
I have two tables invoices and pending_payments both of which have the following rows
If I have an Invoice Line Items table and a Products table, and I
I have a Winform app which lists a batch of invoices in a gridview.
I have a company table that is dbo.companies and has companyId as a column.
I have a WSGI application that generates invoices and stores them as PDF. So
I have a number of records in a model called Kases, each kase record
I have the following table <table id=invoice> <tr> <th>Quantity</th> <th>Item</th> <th><input type=button id=addnew name=addnew
I have a table of invoices. My service layer knows how to calculate the
I have an invoice table like this: Bill Item Qty Weight Rate Amount Advance

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.