SELECT p.*,p.city as pcity,p.lat as plat,p.lng as plng,mk.name AS make_name,mo.name AS model_name,bt.icon,bt.name AS body_type,(SELECT image FROM post_pictures WHERE post_id=p.id ORDER BY img_order ASC LIMIT 1) AS image,di.city AS city_name,di.lat,di.lng, ( ( ( acos( sin(( 39.0481 * pi() / 180)) * sin(( radians(p.lat) * pi() / 180)) + cos(( 39.0481 * pi() /180 )) * cos(( radians(p.lat) * pi() / 180)) * cos((( -77.4728 - radians(p.lng)) * pi()/180))) ) * 180/pi() ) * 60 * 1.1515 * 1.609344 ) as distance FROM posts p LEFT JOIN companies mk ON mk.id=p.make_id LEFT JOIN models mo ON mo.id=p.model_id LEFT JOIN body_types bt ON bt.id=p.body_type_id LEFT JOIN users di ON di.id=p.user_id WHERE p.status = 1 AND (SELECT image FROM post_pictures WHERE post_id=p.id ORDER BY img_order ASC LIMIT 1)<>"" AND p.description <>"" GROUP BY p.id ORDER BY distance DESC LIMIT 10,10