Select closest numerical value with MySQL query

后端 未结 3 1776
温柔的废话
温柔的废话 2020-12-03 11:39

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:

3条回答
  •  悲哀的现实
    2020-12-03 12:08

    In order to use an index, you could select the minimum value above the target, and the maximum value below. Then you only have two values to check.

提交回复
热议问题