1

I am trying to run following query in localhost (Sequel pro) is giving me correct output but when I am trying to run it on production 'distance' and 'branch_name' fields are empty. Local MySQL version is 5.5.58 and production MySQL version is 5.7.2

Here is the query.

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); 

Local output

Local output screenshot

Production output

Production output screenshot

Isaac Bennetch
  • 11,830
  • 2
  • 32
  • 43

0 Answers0