generateAdsByGPS2 SELECT
`id`,
`service_type`,
`adtype`,
`name`,
`interstate`,
`milemarker`,
`address`,
`city`,
`state`,
`zip`,
`latitude`,
`longitude`,
`description`,
`image`,
`category`,
`subcategory`,
`phone`,
`fax`,
`afterhours`,
`website`,
`website2`,
`email`,
`specials`,
`cid`,
`247`,
`hours`,
`special_hours`,
`impressions`,
`ameneties`,
`fuel_price`,
`fuel_updated`,
`status`,
`merchant_type`,
CONCAT(UPPER(city), ',' , UPPER(state)) AS city_state,
3956 * 2 * ASIN(SQRT( POWER(SIN(( - latitude)*pi()/180/2),2)
+COS(*pi()/180 )*COS(latitude*pi()/180)
*POWER(SIN((-longitude)*pi()/180/2),2)))
as distance
FROM ads
WHERE
longitude between (-250/cos(radians())*69)
and (+250/cos(radians())*69)
and latitude between (-(250/69))
and (+(250/69))
and `approved` != 'suspend'
and `status` = 1
and `zip` != 0
and `category` LIKE '%Repair Shops%'
and `subcategory` LIKE '%Truck Shops%'
having distance < 250
ORDER BY distance
limit 100