If the primary keys of records are 1,3,4,5,6,8
1,3,4,5,6,8
I want to select entries using pk: 1,6
1,6
Note
I do not know which identifiers are not sequential
SELECT * FROM your_table AS a LEFT JOIN your_table AS b ON a.key_column = b.key_column - 1 WHERE b.key_column IS NULL
Why not use the where clause in your SQL query?
where
select * from your_table where id in (1, 6)
How about this?
SELECT * FROM [MyTable] WHERE [MyId] NOT IN ( SELECT [MyId] - 1 FROM [MyTable] )
Remember that in your database of choice, rows are usually not "sequential" unless you specifically order them. They simply often appear in the correct order when you do not specify the order.
A slight improvement for the solution proposed by Robin Day
SELECT [MyId] + 1 FROM [MyTable] WHERE [MyId] NOT IN ( SELECT [MyId] - 1 FROM [MyTable] ) ORDER BY [MyId] + 1
Source: https://habr.com/ru/post/1304350/More articles:how to adjust default width of taglist window in vim - vimBlackberry - disable save function in BasicEditField? - user-interfacePHP - while loop - loopsZend Studio cannot detect Zend Server - phpFacebook-.NET Development - What Architecture? - asp.netIs there a (simple) way to get memory usage in a Lua table? - memory-managementMap UIView subregion to UIScrollView - iphoneJunit Exceptional Test - javajavascript number split - javascriptWhat is class level locking in java - javaAll Articles