저는 저장 한 $ eastings $ northings 좌표와 mysql의 테이블에 저장 한 Eastings/Northings 좌표 사이의 거리를 찾으려고합니다. 나는 Laravel을 사용하고있다. 어떤 이유로 쿼리가 작동하지 않습니다.mysql 거리 쿼리가 laravel에서 작동하지 않습니다.
public function postAnalysis(){
$relevant_home = Input::get('relevant_homes');
$asset = Home::where('Home_name', '=' , $relevant_home)->first();
$Eastings = $asset->Eastings;
$Northings = $asset->Northings;
/*
$competitors = Home::raw('SELECT SQRT(POW($Eastings - `Eastings`,2) + POW($Northings - `Northings`,2)) as distance FROM homes HAVING distance <=10 ORDER BY distance ASC')->get();
echo $competitors;
*/
$competitors = DB::table('homes')
-> select(DB::raw('SQRT(POW('.$Eastings.' - Eastings,2) + POW('.$Northings.' - Northings,2)) AS distance'))
-> where('distance', '<', 10)
-> get();
echo $competitors;
}
표시되는 오류는 다음과 같습니다 :
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'distance' in 'where clause' (SQL: select SQRT(POW(390120 - Eastings,2) + POW(298935 - Northings,2)) AS distance from `homes` where `distance` < 10)
'작동하지 않음'은 무엇을 의미합니까? 어떤 오류가 발생합니까? – Quasdunk
거리를 계산하고 있으므로 –
고맙습니다. –