I have spent about two hours testing various SQL calls to pull data from three tables and check for missing data.
Here are my three tables:
fields: f_name, l_name, year, a_id (primary Key), photo, gender, active
fields: id (primary key), a_id (foreign key athletes table), s_id (foreign key schedule table), time, place, dnr
fields, s_id (primary key), location, time, date
I want to be able to pull all athletes who have yet to have a results for a given scheduled event.
I can pull athletes that have entries for the event easily enough but I need the opposite.
The following pulls all the athletes and registers any that have an entry in results:
But when I want to check against a specific event and look for athletes that don't have entries.
LEFT JOIN results ON athlete.a_id = results.a_id
LEFT JOIN schedule ON results.m_id = schedule.s_id