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
Post a Comment