I have two tables, call them Table1 and Table2. Table1 has a primary key of "ID" and Table2 has a foreign key field called "Table1ID".
I can run this join, but it will only work the way I want it to when there is a matching primary and foreign key value in both tables.
SELECT a.*, sum(b.Time) AS Time FROM Table1 AS a JOIN Table2 AS b ON a.ID = b.Table1ID
As you can see, I'm trying to pull all fields from Table1 and a sum of the field "Time" in Table2, where the primary and foreign keys match.
If there isn't a foreign key, I still want the record from Table1 to display, the "Time" field should simply show a 0.