A
A
Apxu2018-08-10 15:40:09
MySQL
Apxu, 2018-08-10 15:40:09

How to make an unusual sort using SQL?

Good day to all!
Please tell me how to form sql to get the following result.
For example, the database contains the following lines:
id | .
_
_
_
_
_
_ we have to get back 50+38(50-12)... This is as an option, but you can suggest some other way - the main task is to get the elements that are next to the given ID using SQL
. Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2018-08-10
@Apxu

(select ... from tablename where id < 88 order by id desc limit 50)
union all
(select ... from tablename where id > 88 order by id asc limit 50)
order by id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question