double left MYSQL join?
Posted
by Haroldo
on Stack Overflow
See other posts from Stack Overflow
or by Haroldo
Published on 2010-05-01T11:21:53Z
Indexed on
2010/05/01
11:27 UTC
Read the original article
Hit count: 324
I've been trying left joins but as there are 2 joins, i think the problem is the 2nd join roots from table_B not table_A. i am not getting any results where there is the required data in the db. I am not getting a query error
the query (simplified)
SELECT events.*, ven.*, events_genres.*
FROM events
LEFT JOIN ven //OPTIONAL JOIN
ON events.ven_id = ven.ven_id //OPTIONAL JOIN
LEFT JOIN events_genres //REQUIRED JOIN
ON events.event_id = events_genres.event_id //REQUIRED JOIN
WHERE events.date >= '$this->now'
AND
WHERE events_genres.g_id = $g_id //REQUIRED MATCH
ORDER BY date
ven = optional, i'll have the info if its there.
events_genres = required, i dont want any results that do not have a genre
© Stack Overflow or respective owner