I'm trying to perform a search on a database across multiple tables. There is a main table called 'events' with most of the data to be searched, but also several other tables that the main table has a foreign key to (ex. meetingroom). The problem is that much of the data stored in the other tables is optional, so a foreign key to it may or may not exist. For instance, a meetingroom was not chosen on a form, so the foreign key to it would be null in the Events table.
At first when making the search query, I simply joined all the tables through the appropriate foreign keys (WHERE events.meetingroom = meetingroom.id) and such. However, if a foreign key was null, an entire row will be left out of the results because it didn't meet the conditions of the join, even though a match for the search may have been found in the main table, or in other tables. Is there any way to change the following query so that it will still return rows when one of the foreign keys that is a condition for the join is NULL? Sorry, I'm a little weak in this area. Maybe a snippet from the query will help, I removed a lot of the extra detail.
SELECT Events.id, Events.title, Events.description, location.location, meetingroom.meetingroom, audience.audience
FROM Events, location, meetingroom, audience WHERE Events.location = location.id AND Events.meetingroom = meetingroom.id AND Events.audience = audience.id AND (Events.title LIKE '%searchterm%' OR Events.description LIKE '%searchterm%' OR location.location LIKE '%searchterm%' OR meetingroom.meetingroom LIKE '%searchterm%' OR audience.audience LIKE '%searchterm%')