我试图在 localhost (Sequel pro)中运行以下查询,但给我正确的输出,但是当我尝试在 production 'distance'和' branch_name'字段为空。 本地MySQL版本是5.5.58,生产MySQL版本是5.7.2
这是查询。
SELECT *,
@distance AS distance,
@branch_name AS branch_name
FROM `bg_offers`
WHERE `end_datetime` > 2019 - 12 - 12
AND EXISTS (SELECT *,
@branch_name := branches.branch_name,
@distance := ( 6371 * Acos(Cos(Radians(25.2097)) *
Cos(Radians(map_latitude))
*
Cos(
Radians(map_longitude)
- Radians(
55.2478)
) + Sin
(
Radians(25.2097)) *
Sin(Radians(map_latitude)
)) ) AS distance
FROM `branches`
INNER JOIN `bg_offer_branches`
ON `branches`.`id` =
`bg_offer_branches`.`branch_id`
WHERE `bg_offers`.`id` = `bg_offer_branches`.`bg_offer_id`
HAVING `distance` <= 60000000
ORDER BY `distance` ASC);
本地输出
生产输出