Hey,
I have a problem.
I have a DB table with a collume in witch i saved numbers.
1.123
1.234
4.67854
...
I need to get the number that is closest or equal to 2.3. In that example 1.234.
How do I do that? If I use like or = in a MySQL DB query I get just a replay if 2.3 is in the DB, but not the closest.
I looked a usort, but i wasen't able to do it.
greetings an thanks
shark86
[SOLVED] closest number?
Moderator: General Moderators
[SOLVED] closest number?
Last edited by shark86 on Tue Jun 15, 2004 11:41 am, edited 1 time in total.
Code: Select all
select numberr from numbers order by abs($num_to_search_for-numberr) limit 1