I have a SQL database with 2 tables and I need to get this data in ONE REQUEST to the server.
I am trying to get the startDate, endDate, and title data from the event table
Then I am also trying to get the source and eventId data from the photo table
So far, i have this which works perfect, but there's one problem.
SELECT event.startDate, event.endDate, event.id, event.title, photo.source, photo.eventId FROM event, photo
WHERE event.id = 'UNIQUE ID NUMBER' AND photo.eventId = 'UNIQUE ID NUMBER';
Sometimes, the photo.eventId is equal to NULL meaning that nothing will return. If this is the case, the only data I need is data from the first table event which is the three columns startDate, endDate, and title
The return should then have the same output as this:
SELECT event.startDate, event.endDate, event.id, event.title FROM event WHERE event.id = 'UNIQUE ID NUMBER';