I have stored in my table two fields lat and long, these columns have the datatype of VARCHAR
Now in Laravel I have the following variables:
$ne_lat = 21.405122657695813;
$ne_lng = -102.32061363281252;
$sw_lat = 19.984311565790197;
$sw_lng = -104.19652916015627;
Wich I want to use in my query to compare it against my table data like this:
$agencies = DB::table('users')
->whereRaw('lat < ? AND lat > ? AND long < ? AND long > ?',[$ne_lat,$sw_lat,$ne_lng,$sw_lng])
I've tried to CAST it like this:
$agencies = DB::table('users')
->whereRaw('CAST(lat AS FLOAT) < ? AND CAST(lat AS FLOAT) > ? AND CAST(long AS FLOAT) < ? AND CAST(long AS FLOAT) > ?',[$ne_lat,$sw_lat,$ne_lng,$sw_lng])
But it doesn't display any results (I'm not getting any error messages since the query shows up in json) it just doesn't show up. What am I doing wrong with my query?
Thanks in advance