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

  • SEARCH
  • Home
  • 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 9113929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:04:57+00:00 2026-06-17T04:04:57+00:00

I am having trouble getting my database to stay organized I would like the

  • 0

I am having trouble getting my database to stay organized I would like the ID field which is set to an INT PRIMARY KEY AUTO_INCREMENT to stay in numerical order. The problem comes when I delete all of the entries in the database. Before deleting the entries everything is in order as intended, after deleting instead of going in numerical order starting with the smaller integer first it will always go in descending order. Can someone explain what is causing this.

+----+------------+----------+---------+----------------+-----------+------------+-----------+---------+
| id | employeeID | date     | timeIn  | jobDescription | equipType | unitNumber | unitHours | timeOut |
+----+------------+----------+---------+----------------+-----------+------------+-----------+---------+
|  1 |          2 | 01/13/13 | 1:19 pm | Test1          | Dozer     | 1D         |        98 | 1:20 pm |
|  2 |          2 | 01/13/13 | 1:20 pm | Test2          | Dozer     | 1D         |        98 | 1:20 pm |
+----+------------+----------+---------+----------------+-----------+------------+-----------+---------+

AFTER DELETING ALL ROWS:

+----+------------+----------+---------+----------------+-----------+------------+-----------+---------+
| id | employeeID | date     | timeIn  | jobDescription | equipType | unitNumber | unitHours | timeOut |
+----+------------+----------+---------+----------------+-----------+------------+-----------+---------+
|  4 |          2 | 01/13/13 | 1:22 pm | Test2          | Dozer     | 1D         |        98 | 1:22 pm |
|  3 |          2 | 01/13/13 | 1:22 pm | Test1          | Dozer     | 1D         |        98 | 1:22 pm |
+----+------------+----------+---------+----------------+-----------+------------+-----------+---------+
  • 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-06-17T04:04:59+00:00Added an answer on June 17, 2026 at 4:04 am

    Remember that without an ORDER BY clause in your SELECT query, the order is effectively not deterministic and you cannot and should not rely on it being in any particular order.

    What I see here is Test2 inserted with id=4, and assuming you first inserted the Test1 row, then your auto_increment is working as expected.

    If you simply did something like SELECT * FROM thistable, do not expect the rows to be ordered by id ASC. Add an ORDER BY clause to be explicit about it.

    SELECT * FROM thistable ORDER BY id ASC
    

    Since all the other columns between these two new rows have equal values, whichever column MySQL has chosen to sort on absent an explicit ORDER BY doesn’t have anything to differentiate.

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

Sidebar

Related Questions

I am having trouble getting things moved in a database. I have two tables
After deploying an app of Heroku I am having trouble getting the database populated
So I am having trouble getting the information I pull from the database order
I'm trying to design a recipe box database and I'm having trouble getting it
Having trouble getting this done. I am using seed.rb + factory_girl to populate database
I am having trouble getting my website to display a database entry correctly. I
Having trouble getting my form to UPDATE records in my database even after searching
I'm having trouble getting all the data out of the database and I'm not
I'm having trouble getting this function work. This is my database design I'm working
I'm having trouble getting my image files to appear from the database info. If

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.