![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have an integer column, and I want to search a value that could not be there. Example column values: 114,54,223,67,187,991 Example search value: 100 How to find row 100 (if exists) or the most approximated value 114? My actual solution is: SELECT * FROM table WHERE column < search ORDER BY column DESC LIMIT 0,1 SELECT * FROM table WHERE column > search ORDER BY column DESC LIMIT 0,1 But my doubt is: Is there any function to do this in MySQL? |
|
x | +-----+ 114 | +-----+ |
![]() |
| Thread Tools | |
| Display Modes | |
| |