· 8 years ago · Dec 24, 2017, 06:22 PM
1CREATE TABLE IF NOT EXISTS `sequence` (
2 `id` int(6) unsigned NOT NULL,
3 PRIMARY KEY (`id`)
4) DEFAULT CHARSET=utf8;
5INSERT INTO `sequence` (`id`) VALUES
6 ('1'),
7 ('2'),
8 ('4'),
9 ('5'),
10 ('6'),
11 ('8'),
12 ('10');
13
14
15SELECT
16 fst.id+1
17 #,snd.id
18 #,thd.id
19FROM
20 sequence AS fst
21LEFT JOIN
22 sequence AS snd
23ON fst.id = (snd.id - 1)
24LEFT JOIN
25 sequence AS thd
26ON fst.id = (thd.id + 1)
27WHERE snd.id is NULL LIMIT 1 OFFSET 1;