Created
June 28, 2016 11:04
-
-
Save nkgokul/1fc9ea7b2d16f1063cf24976b3cce958 to your computer and use it in GitHub Desktop.
Missing nids from node table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT (t1.nid + 1) as gap_starts_at, | |
(SELECT MIN(t3.nid) -1 FROM node t3 WHERE t3.nid > t1.nid) as gap_ends_at | |
FROM node t1 | |
WHERE NOT EXISTS (SELECT t2.nid FROM node t2 WHERE t2.nid = t1.nid + 1) | |
HAVING gap_ends_at IS NOT NULL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For users
SELECT (t1.uid + 1) as gap_starts_at,
(SELECT MIN(t3.uid) -1 FROM users t3 WHERE t3.uid > t1.uid) as gap_ends_at
FROM users t1
WHERE NOT EXISTS (SELECT t2.uid FROM users t2 WHERE t2.uid = t1.uid + 1)
HAVING gap_ends_at IS NOT NULL