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

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

Ansible warning on jinja2 braces on when -