Hi,
I am trying to find a way to get a list of numbers that are NOT in my
db.
Is there a way to do this with a MySQL statement, or do I have to write
a
script that does this?
To be more exact: I have a table with an auto_increment data-id. This
table is automatically updated and some values get deleted each time.
Now
I want to find out, what numbers are not used any more.
If the ID numbers in your table run from 1 to n, and you have another table with the values 1 to n with no missing values, you can compare the two tables and see which ID numbers are missing in your first table. Otherwise, you can limit your script to a single loop and do everything else in SQL.
1) Create a temp table with 1 column.
2) Have the script loop insert all the values from 1 to n into the temp table.
3) Use the LEFT JOIN technique to compare the temp table with the data table and
return the missing values.
SELECT temp.id
FROM temp LEFT JOIN data ON temp.id = data.id
WHERE data.id IS NULL;
Bob Hall
Know thyself? Absurd direction!
Bubbles bear no introspection. -Khushhal Khan Khatak