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 3496986
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:18:57+00:00 2026-05-18T12:18:57+00:00

BIG UPDATE: Ok I was getting the whole auto-increment point wrong. I though this

  • 0

“BIG” UPDATE:

Ok I was getting the whole
auto-increment point wrong. I though
this would be an easier way to target
the first, second, third and so row,
but it is just the wrong approach.

You should instead care about that the
auto_increments are unique and well…
that they increment. You should use
the for that.

I wont delete this question because I
think it might be helpful for someone
else with the same wrong idea, BUT
BE WARNED!
🙂


I have a very simple MySQL table which went like this:

id    comment    user

1     hello      name1
2     bye        name2
3     hola       name3

Then I deleted the two first comments, the result:

id    comment    user

3     hola      name3

So now when I add comments:

id    comment    user

3     hola      name3
5     chau      name4
6     xxx       name5

My problem is that I would need that whenever a row gets deleted it should “start over” and look like this.

id    comment    user

1     hola      name3
2     chau      name4
3     xxx       name5

I would like to know how is it possible to some how “restart” the table so that it is “always” indexed 1, 2, 3 and so on.

Thanks in advance!!


I hope I have explained myself clear enough, I’m sorry for all my “plain english”, feel free to edit if you think a word might be confusing 🙂 and please ask for any clarification needed!

BTW: I did not add any of my code because this is a simplified situation and I though it be more confusing and less helpful to others, but I you think it would help (or is necessary) tell me about it!

  • 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-18T12:18:58+00:00Added an answer on May 18, 2026 at 12:18 pm

    Can’t be done using MySQL’s autoincrement feature. You could roll your own solution, e.g. a mix between application logic and database triggers. BUT, seriosly, your design is heavily broken if it requires you to recycle UNIQUE IDs.

    Couldn’t you just create another table where you’d save references like that (this could be done by querying the minimum) and let your main table point to that auxilliary table?

    EDIT
    Here’s a blog I’ve googled that deals with your problem: see here.

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

Sidebar

Related Questions

UPDATE 2 This is a known bug/feature with the way Ruby 1.9.2 loads files.
I have a big string (let's call it a CSV file, though it isn't
What is Big O notation? Do you use it? I missed this university class
Update OK, after some investigation, and thanks in big part to the helpful answers
Big problem. I'm not sure what it was that I did, but it seems
I am reviewing a big java application to see if there are any performance
It's big problem to convert mod_rewrite rules to lighttpd format
Server virtualization is a big thing these days, so I'm tasked at work to
i have a big web application running in perl CGI. It's running ok, it's
I'm a big fan of the Jadclipse plugin and I'd really like to upgrade

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.