php - Find closest match in a column using laravel -


i'm wondering how can find closest value matches number table. have is:

$result = db::table('numbers')             ->orderby('s/me - $input', 'desc')             ->get(); 

s/me being column name want find match. keeps giving me interface 'throwable' not found error.

you can this:

$result = db::table('numbers')             ->select('*', db::raw("abs(s/me - $input) distance"))               ->orderby('distance')             ->get(); 

credits source here.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -