This relates to a webpage that should show all upcoming events, and mark any that are in the current user’s diary.
diary table
diary_id
member_id
event_id
event table
event_id
region_id
…
region table
region_id
…
member table
member_id
…
QUERY:
SELECT event.*, region.name, diary.diary_id
FROM event, region
LEFT JOIN diary on diary.member_id = 10 AND diary.event_id = event.event_id
WHERE region.region_id = event.region_id AND `date` >= NOW()
This is returning unknown column event.event_id and I can’t figure out why. I’m no SQL whiz but expected this would just work and give me a NULL in the diary_id column for all events that are not in the user’s diary
You are mixing
joinsyntax. Try this instead.Update
Your problem with not finding
event_idis because of thisFROM event, region. It can’t findevent_idin theonclause. Change your query as suggested above but it would also be possible to fix it by switching places of the tables toFROM region, event. Don’t do that. Use the new join syntax introduced to the SQL language some 20 years ago.