So... I want to select 5 records from a database that are closest to a given number.
Example:
Here is my data:
1
2
3
4
5
6
7
8
9
10
I want to select the 5 closest records to 6.
So it would return 3, 4, 5, 6, 7.
How would I go about doing this with mysql.
Extra credit for using an order by to return the results ordered by closest to 5 ( 5, 4, 6, 3, 7 or 5, 6, 4, 7, 3).
EDIT:
http://forums.devshed.com/postgresql-help-21/sele...record-175109.html
Found what I needed. Might be useful for someone else down the road here.