我收到错误:
Column not found: 1054 Unknown column 'distance' in 'order clause'
这是我的疑问:
$place = $place->selectRaw("(3959 * acos(cos(radians(?)) * cos(radians(lat)) * cos(radians(lng) - radians(?)) + sin(radians(?)) * sin(radians(lat)))) as distance", array($filters['location']['lat'], $filters['location']['lng'], $filters['location']['lat']))
->orderBy('distance', 'ASC')
->having('distance', '<', 50);
出于某种原因,距离&#39;在原始选择中没有被订单接收。解决方案是什么?
从toSql()我得到:
"select (3959 * acos(cos(radians(?)) * cos(radians(lat)) * cos(radians(lng) - radians(?)) + sin(radians(?)) * sin(radians(lat)))) as distance from `products` where `products`.`deleted_at` is null having `distance` < ? order by `distance` asc"