Hi all...
I'm working on an address search feature for my site, and can't figure out how to combine different functions in a MySQL query using PHP.
I'm trying to combine the functions of this query:
$query = sprintf("SELECT *, ( 3959 * acos( cos( radians( $center_lat ) ) * cos( radians( showtimes_venues.location_lat ) ) * cos( radians( showtimes_venues.location_lng ) - radians( $center_lng ) ) + sin( radians( $center_lat ) ) * sin( radians( showtimes_venues.location_lat ) ) ) ) AS distance FROM markers HAVING distance < '%s' ORDER BY distance LIMIT 0 , 20",
mysql_real_escape_string($center_lat),
mysql_real_escape_string($center_lng),
mysql_real_escape_string($center_lat),
mysql_real_escape_string($radius));
...into this query:
$query="
SELECT * FROM showtimes_showings
JOIN showtimes_venues
ON showtimes_showings.venue_id = showtimes_venues.venue_id
LEFT JOIN showtimes_casts
ON showtimes_showings.cast_id = showtimes_casts.cast_id
ORDER BY showtimes_venues.address_country, showtimes_venues.address_stateprov, showtimes_venues.address_city, showtimes_venues.name, showtimes_venues.subname, showtimes_showings.date_start DESC, showtimes_showings.date_end DESC
";
I'm not sure how to combine all of this so that the query actually works. Can one even use sprintf with JOINs?
-David