Your question, your audience. Choose who sees your identityâ€”and your questionâ€”with question security.
SELECT event.id,event.category_id, date.id AS date_id , 6371.04 * acos( cos( pi( ) /2 - radians( 90 - venue.lat) ) * cos( pi( ) /2 - radians( 90 - '52.486243' ) ) * cos( radians( venue.lon) - radians( '-1.890401' ) ) + sin( pi( ) /2 - radians( 90 - venue.lat) ) * sin( pi( ) /2 - radians( 90 - '52.486243' ) ) ) AS distance FROM events AS event, venues AS venue,event_dates AS date WHERE event.venue_id = venue.id AND ((event.cost_from >= '10.00' OR event.cost_from <= '75.00') OR (event.cost_to >= '10.00' OR event.cost_to <= '75.00')) GROUP BY event.id HAVING distance < '25' ORDER BY distance ASC LIMIT 0,20
SELECT
event.id
, event.category_id
, DATE.id AS date_id
, 6371.04 * ACOS(COS(PI() / 2 - RADIANS(90 - venue.lat)) * COS(PI() / 2 - RADIANS(90 -
'52.486243')) * COS(RADIANS(venue.lon) - RADIANS('-1.890401')) + SIN(
PI() / 2 - RADIANS(90 - venue.lat)) * SIN(PI() / 2 - RADIANS(90 - '52.486243'))) AS
distance
FROM events AS event
, venues AS venue
, event_dates AS DATE /* how is this joined ??????? */
WHERE event.venue_id = venue.id
AND (
(event.cost_from >= '10.00' OR event.cost_from <= '75.00')
OR (event.cost_to >= '10.00'OR event.cost_to <= '75.00')
)
GROUP BY
event.id
HAVING distance < '25'
ORDER BY
distance
FROM events AS event
INNER JOIN venues AS venue ON event.venue_id = venue.id
INNER JOIN event_dates AS date ON
it's impossible to leave line 3 like that (the query would just fail) and hence you are forced to provide the relationship(s).
Open in new window