gpt4 book ai didi

php - mysql 查询中出现未知列错误

转载 作者:行者123 更新时间:2023-11-29 13:19:42 25 4
gpt4 key购买 nike

我正在计算装载点和交货点之间的半径。

我已经对其进行了查询,但它给了我错误:

未知的列距1

这是查询:

SELECT ( ( Acos(Sin('49.4634' * Pi() / 180) * Sin(
`locationlatitudestart` * Pi() / 180)
+
Cos(
'49.4634' * Pi() / 180) * Cos(
`locationlatitudestart` * Pi()
/
180) * Cos((
'3.54404' - `locationlongitudestart` ) * Pi() /
180)) *
180 / Pi() ) * 60 * 1.1515 ) AS distance1,
( ( Acos(Sin('48.8637' * Pi() / 180) * Sin(
`locationlatitudeend` * Pi() / 180) +
Cos
(
'48.8637' * Pi() / 180) * Cos(
`locationlatitudeend` * Pi() / 180) *
Cos
((
'2.36109' - `locationlongitudeend` ) * Pi() / 180)) *
180 / Pi
()
) * 60 * 1.1515 ) AS distance2,
( ( Acos(Sin('49.4634' * Pi() / 180) * Sin(
`locationlatitudeend` * Pi() / 180) +
Cos
(
'49.4634' * Pi() / 180) * Cos(
`locationlatitudeend` * Pi() / 180) *
Cos
((
'3.54404' - `locationlongitudeend` ) * Pi() / 180)) *
180 / Pi
()
) * 60 * 1.1515 ) AS distance3,
( ( Acos(Sin('48.8637' * Pi() / 180) * Sin(
`locationlatitudestart` * Pi() / 180)
+
Cos(
'48.8637' * Pi() / 180) * Cos(`locationlatitudestart` * Pi()
/ 180)
*
Cos((
'2.36109' - `locationlongitudestart` ) * Pi() / 180)) *
180 /
Pi
() ) * 60 * 1.1515 ) AS distance4
FROM instant_quotes
WHERE distance1 <= locationradiusstart
AND distance2 <= locationradiusend
OR distance3 <= locationradiusend
AND distance3 <= locationradiusstart

最佳答案

使用下面的查询 - 使用having子句而不是where --

 SELECT ((ACOS( SIN( '49.4634' * PI( ) /180 ) * SIN( `LocationLatitudeStart` * PI( ) /180 ) + COS( '49.4634' * PI( ) /180 ) * COS( `LocationLatitudeStart` * PI( ) /180 ) * COS( ( '3.54404' - `LocationLongitudeStart` ) * PI( ) /180 ) ) *180 / PI( ) ) *60 * 1.1515 ) AS distance1 ,
((ACOS( SIN( '48.8637' * PI( ) /180 ) * SIN( `LocationLatitudeEnd` * PI( ) /180 ) + COS( '48.8637' * PI( ) /180 ) * COS( `LocationLatitudeEnd` * PI( ) /180 ) * COS( ( '2.36109' - `LocationLongitudeEnd` ) * PI( ) /180 ) ) *180 / PI( ) ) *60 * 1.1515 ) AS distance2,
((ACOS( SIN( '49.4634' * PI( ) /180 ) * SIN( `LocationLatitudeEnd` * PI( ) /180 ) + COS( '49.4634' * PI( ) /180 ) * COS( `LocationLatitudeEnd` * PI( ) /180 ) * COS( ( '3.54404' - `LocationLongitudeEnd` ) * PI( ) /180 ) ) *180 / PI( ) ) *60 * 1.1515 ) AS distance3 ,
((ACOS( SIN( '48.8637' * PI( ) /180 ) * SIN( `LocationLatitudeStart` * PI( ) /180 ) + COS( '48.8637' * PI( ) /180 ) * COS( `LocationLatitudeStart` * PI( ) /180 ) * COS( ( '2.36109' - `LocationLongitudeStart` ) * PI( ) /180 ) ) *180 / PI( ) ) *60 * 1.1515 ) AS distance4
FROM instant_quotes having distance1 <= LocationRadiusStart AND distance2 <= LocationRadiusEnd OR distance3 <= LocationRadiusEnd AND distance3 <= LocationRadiusStart

关于php - mysql 查询中出现未知列错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21019222/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com