我想查询附近的用户,但出现此错误:
SQLSTATE [42000]:语法错误或访问冲突:1582对本机函数'radians'的调用中的参数计数不正确(SQL:select *,(6367 * acos(cos(radians())* cos(radians(纬度) ))* cos(弧度(弧度-弧度())+ sin(弧度())* sin(弧度(纬度)))))与距离≤25的用户之间的距离
我的查询
$user = User::where('id' , Auth()->user()->id)->first();
$latitude = $user->lat;
$longitude = $user->long;
$suggestions = User::select(DB::raw('*, ( 6367 * acos( cos( radians('.$latitude.') ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians('.$longitude.') ) + sin( radians('.$latitude.') ) * sin( radians( latitude ) ) ) ) AS distance'))
->having('distance', '<', 25)
->orderBy('distance')
->get();