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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:10:25+00:00 2026-05-23T19:10:25+00:00

I got a table with a normal setup of auto inc. ids. Some of

  • 0

I got a table with a normal setup of auto inc. ids. Some of the rows have been deleted so the ID list could look something like this:

(1, 2, 3, 5, 8, …)

Then, from another source (Edit: Another source = NOT in a database) I have this array:

(1, 3, 4, 5, 7, 8)

I’m looking for a query I can use on the database to get the list of ID:s NOT in the table from the array I have. Which would be:

(4, 7)

Does such exist? My solution right now is either creating a temporary table so the command “WHERE table.id IS NULL” works, or probably worse, using the PHP function array_diff to see what’s missing after having retrieved all the ids from table.

Since the list of ids are closing in on millions or rows I’m eager to find the best solution.

Thank you!
/Thomas

Edit 2:

My main application is a rather easy table which is populated by a lot of rows. This application is administrated using a browser and I’m using PHP as the intepreter for the code.

Everything in this table is to be exported to another system (which is 3rd party product) and there’s yet no way of doing this besides manually using the import function in that program. There’s also possible to insert new rows in the other system, although the agreed routing is to never ever do this.

The problem is then that my system cannot be 100 % sure that the user did everything correct from when he/she pressed the “export” key. Or, that no rows has ever been created in the other system.

From the other system I can get a CSV-file out where all the rows that system has. So, by comparing the CSV file and my table I can see if:
* There are any rows missing in the other system that should have been imported
* If someone has created rows in the other system

The problem isn’t “solving it”. It’s making the best solution to is since there are so much data in the rows.

Thanks again!

/Thomas

  • 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-23T19:10:25+00:00Added an answer on May 23, 2026 at 7:10 pm

    We can use MYSQL not in option.

    SELECT id
    FROM table_one
    WHERE id NOT IN ( SELECT id FROM table_two )
    

    Edited

    If you are getting the source from a csv file then you can simply have to put these values directly like:

    I am assuming that the CSV are like 1,2,3,…,n

    SELECT id
    FROM table_one
    WHERE id NOT IN ( 1,2,3,...,n );
    

    EDIT 2

    Or If you want to select the other way around then you can use mysqlimport to import data in temporary table in MySQL Database and retrieve the result and delete the table.

    Like:

    Create table

    CREATE TABLE my_temp_table(
       ids INT,
    );
    

    load .csv file

    LOAD DATA LOCAL INFILE 'yourIDs.csv' INTO TABLE my_temp_table
    FIELDS TERMINATED BY ','
    LINES TERMINATED BY '\n'
    (ids);
    

    Selecting records

    SELECT ids FROM my_temp_table
    WHERE ids NOT IN ( SELECT id FROM table_one )
    

    dropping table

    DROP TABLE IF EXISTS my_temp_table
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got a table which is coming with some data. One of the
I've got a table with a header, a row with input fields, rows with
I have got a table in MS Access 2007 with 4 fields. Labour Cost
I've got a table that has some <input type=text> boxes in it, and I
I've got a tr:table that I need to style using CSS. All the normal
Got a table with 1200 rows. Added a new column which will contain incremental
Ive got a table with a many rows, currently no fields are unique. I've
I've got a table and it has rows that are collapsible when clicked on
I've got a table with an auto-increment number field As No, a date/time stamp
I've got a table with some nullable double fields. Working with LinqToSQL trying to

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.