If you have a table of incremental values it can be hard to find out which ones are missing. The only solution might be to write a script to get all the data from the database and see which ones are missing. However, there is a way of doing this without using a script.
Using a standard select query like this:
- <p>Gets the following data:</p>
- <pre language=">1
We can see that values are missing, but which ones? The following query will show us where the gaps are in the data of the table.
- <p>Produces the following result.</p>
- <pre language=" plain="">2
However, this only tell us where the gaps are, not how long they are. To get the range of where the gaps from and to we need to do something a little more complex.
- <p>This query gives the following result.</p>
- <table><tr><th>Missing From</th><th>To</th></tr>
- <p>Using this dataset we can figure out where the gaps in the data are and perhaps do something with them.</p></body></html>">