> I'm looking for an existing function which allows me to search the nearest
> neighbours of the requested value.
Well you could try something like:
SELECT * FROM table ORDER BY ABS(val - 2) LIMIT 1;
That doesn't get you all the way there, but it's an idea...
Chris
Чтобы сделать работу с сайтом удобнее, мы используем cookie и аналитический сервис «Яндекс.Метрика». Продолжая пользоваться сайтом, вы соглашаетесь с их использованием.