SELECT SQL_CALC_FOUND_ROWS  wp_posts.*, ( 3959* acos( cos( radians(40.7291) )
              * cos( radians( CAST(geo_data.latitude AS DECIMAL(10,6)) ) )
              * cos( radians( CAST(geo_data.longitude AS DECIMAL(10,6)) ) - radians(-74.0386) )
              + sin( radians(40.7291) )
              * sin( radians( CAST(geo_data.latitude AS DECIMAL(10,6)) ) ) ) ) AS distance , geo_data.latitude AS latitude , geo_data.longitude AS longitude , wp_posts.ID as business_ID , CONCAT(LCASE((SELECT meta_value FROM wp_postmeta WHERE meta_key='business_city' AND post_id=business_ID )), ', ', LCASE((SELECT meta_value FROM wp_postmeta WHERE post_id=business_ID AND meta_key='business_state'))) AS business_loc, offer_cn_meta.offer_id AS offer_id , offer_cn_meta.offer_cashback_amount AS offer_cashback , offer_cn_meta.offer_service_id AS offer_service_id , offer_cn_meta.offer_date AS offer_date  FROM wp_posts  INNER JOIN wp_profile_addresses AS geo_data ON wp_posts.ID = geo_data.profile_ID 
						INNER JOIN wp_business_offers as offer_cn_meta
						ON  (offer_cn_meta.profile_ID=wp_posts.ID)
						 INNER JOIN wp_term_relationships as offers_cat on (offers_cat.object_id = offer_cn_meta.offer_id AND offers_cat.term_taxonomy_id IN ('1311') ) 
						 WHERE 1=1  AND wp_posts.post_type = 'business' AND ((wp_posts.post_status = 'publish')) AND geo_data.geo_fetched=1  AND ( ( (geo_data.latitude BETWEEN 40.7291 - (100/69.05482) AND 40.7291 + (100/69.05482))  AND (geo_data.longitude BETWEEN -74.0386 - 100/abs(cos(radians(40.7291))*69.05482) AND -74.0386 + 100/abs(cos(radians(40.7291))*69.05482)) )  )  AND offer_cn_meta.offer_status = 'publish'  ORDER BY wp_posts.post_date DESC LIMIT 0, 10
SELECT SQL_CALC_FOUND_ROWS  wp_posts.*, ( 3959* acos( cos( radians(40.7291) )
              * cos( radians( CAST(geo_data.latitude AS DECIMAL(10,6)) ) )
              * cos( radians( CAST(geo_data.longitude AS DECIMAL(10,6)) ) - radians(-74.0386) )
              + sin( radians(40.7291) )
              * sin( radians( CAST(geo_data.latitude AS DECIMAL(10,6)) ) ) ) ) AS distance , geo_data.latitude AS latitude , geo_data.longitude AS longitude , wp_posts.ID as business_ID , CONCAT(LCASE((SELECT meta_value FROM wp_postmeta WHERE meta_key='business_city' AND post_id=business_ID )), ', ', LCASE((SELECT meta_value FROM wp_postmeta WHERE post_id=business_ID AND meta_key='business_state'))) AS business_loc, offer_cn_meta.offer_id AS offer_id , offer_cn_meta.offer_cashback_amount AS offer_cashback , offer_cn_meta.offer_service_id AS offer_service_id , offer_cn_meta.offer_date AS offer_date  FROM wp_posts  INNER JOIN wp_profile_addresses AS geo_data ON wp_posts.ID = geo_data.profile_ID 
						INNER JOIN wp_business_offers as offer_cn_meta
						ON  (offer_cn_meta.profile_ID=wp_posts.ID)
						
						 WHERE 1=1  AND wp_posts.post_type = 'business' AND ((wp_posts.post_status = 'publish')) AND geo_data.geo_fetched=1  AND ( ( (geo_data.latitude BETWEEN 40.7291 - (100/69.05482) AND 40.7291 + (100/69.05482))  AND (geo_data.longitude BETWEEN -74.0386 - 100/abs(cos(radians(40.7291))*69.05482) AND -74.0386 + 100/abs(cos(radians(40.7291))*69.05482)) )  )  AND offer_cn_meta.offer_status = 'publish'  ORDER BY wp_posts.post_date DESC LIMIT 0, 10
Compare Local Beauty Prices Near You - CostWinner