SELECT a.id+1 AS start, MIN(b.id) - 1 AS end
FROM testtable AS a, testtable AS b
WHERE a.id < b.id
GROUP BY a.id
HAVING start < MIN(b.id)
Hope this link also helps
http://www.codediesel.com/mysql/sequence-gaps-in-mysql/
More Related Contents:
- How do you use MYSQL in ColdFusion? [closed]
- Using LIMIT within GROUP BY to get N results per group?
- Using backticks around field names
- How do I do a bulk insert in mySQL using node.js
- Reorder / reset auto increment primary key
- Required to join 2 tables with their FKs in a 3rd table
- Save Data in Arabic in MySQL database
- Setting the MySQL root user password on OS X
- How to change the CHARACTER SET (and COLLATION) throughout a database?
- Mysql::Error: Specified key was too long; max key length is 1000 bytes
- GROUP_CONCAT with limit
- How can I get around MySQL Errcode 13 with SELECT INTO OUTFILE?
- SQL Query to show nearest date?
- How can I modify the size of column in a MySQL table?
- How to auto generate migrations with Sequelize CLI from Sequelize models?
- Getting all parent rows in one SQL query
- How can I manipulate MySQL fulltext search relevance to make one field more ‘valuable’ than another?
- Creating functions in phpMyAdmin – Error: access denied you need the super privilege for this operation
- How to connect to MySQL from the command line
- MySQL – Recursing a tree structure
- Remove DEFINER clause from MySQL Dumps
- How to retrieve JSON data from MySQL?
- Is incrementing a field in MySQL atomic?
- Delete from one table with join
- MySQL column type “TIMESTAMP” implicitly includes “NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP”
- Encryption at rest and/or AES_ENCRYPT
- MySQL: Compare BETWEEN time
- How to import large sql file in phpmyadmin
- How to figure out size of Indexes in MySQL
- Failed to connect to mysql at 127.0.0.1:3306 with user root access denied for user ‘root’@’localhost'(using password:YES)