I got a table that looks like that:
ID|DATA
1 | ok
4 | ok2
5 | kk
6 | same ok
7 | k
9 | yeah
I want to find the closest match(round down) to my id. When I pass
id = 8
I want to select the raw 7 | K
How do I do that in mySql
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use this solution:
Alternatively, here’s another way you can do it without having to use
ORDER BY/LIMIT: