I have 2 tables – events and attendees.
I am trying using php to when clicking on the attendee’s list via the events.id and to display the attendees listed in the attendees table linked by id.
fields envolved are events.id and attendees.id and to display the attendees for that event.
This is what I have at the moment.
SELECT events.*, attendees.*
FROM attendees ON event.id = attendees.id
WHERE event.id = attendees.id
Your joining syntax is an incorrect mix of implicit and explicit
JOINsyntaxes, missing theJOINkeyword, and instead duplicating the join condition in theWHEREclause.Note that it is not advisable to use
events.*, attendees.*in PHP, since you will have duplicate column names that become inaccessible to PHP. Instead, be explicit:If you still want to get the event details even if it has no attendees, use a
LEFT JOINinstead: