I have a site where you can see venues. When you click on a single venue it displays a popup with it. There is a favorite button which can be active or not. This code is in ajax for this popup

```
SELECT * FROM venue_datetime
LEFT JOIN venue_calendar ON venue_datetime.calendar = venue_calendar.calendar_id
LEFT JOIN venue_events ON venue_calendar.event = venue_events.event_id
LEFT JOIN venue ON venue_events.venue = venue.venue_id
LEFT JOIN favorites ON venue.venue_id = favorites.favorites_venue_id OR venue.venue_id is null
LEFT JOIN users ON favorites.favorites_user_id = users.id OR favorites.favorites_user_id is null
WHERE datetime_id = ? AND id = ?

```

This part is not working as it was intended.

```
LEFT JOIN favorites ON venue.venue_id = favorites.favorites_venue_id OR venue.venue_id is null
LEFT JOIN users ON favorites.favorites_user_id = users.id OR favorites.favorites_user_id is null

```

Any ideas?