This is probably easier than I am making it, but basically what I need to do is select the row that has the closest number in a column as a specified value. For example:
How would you handle tie breakers? Because this will only take the first:
SELECT t.col FROM TABLE t ORDER BY ABS(t.col - @val) LIMIT 1
Index safe alternative:
SELECT xt.col FROM (SELECT t.col, ABS(t.col - @val) 'diff' FROM TABLE t) xt ORDER BY xt.diff LIMIT 1