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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:31:03+00:00 2026-06-05T21:31:03+00:00

You have a table table1 that contains id column, that is int(11), not null,

  • 0

You have a table table1 that contains id column, that is int(11), not null, auto_increment and starts from 1.

Suppose, you have 10,000 records. It is clear the id of the last record is 10,000.
Once you removed 3 records, you have 9,997 records in the table, but the last record id value is still 10,000 (if the last record was not deleted).

How to display what records have been removed using 1 sql query?

Thank you.

  • 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-05T21:31:05+00:00Added an answer on June 5, 2026 at 9:31 pm

    I think easiest would be to have a dummy/temp table with just ids. 1-1000 then left join to that table.

    But be sure to remove the “deleted” records from your dummy/temp table once you’re done. Otherwise, they will show up every time.

    >> EDIT <<
    You can do self join to figure out if you’re missing ids….

    select a.id + 1 MissingIds
    from <table> a
    left join <table> b
      on a.id = b.id - 1
    where b.id is null
      and a.id < 10000
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table that contains records with a column indicates the Date. Given
I Have the following table: CREATE TABLE `tmp_table` ( `id` int(11) NOT NULL AUTO_INCREMENT,
I have a table that contains the following columns: ID int, DISTANCE float, EVENT
I have a table that contains an Id column as a primary key. There
I have a varchar(100) column in a table that contains a mix of integers
I have the following requirement. I have a table with a column that contains
I have a mysql table that has 2 columns - Column 1 contains a
I have a TABLE elements with one COLUMN number, type SMALLINT that contains numbers
I have a table called Order_List that contains a list of orders. Each column
I have a table that contains several thousand rows, having a Varchar column that

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.