> 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