I have 3 tables. Table 1 has an ID field in it. Tables 2 and 3 have an FK pointing back to table 1’s ID. I need to get all data from all 3 tables without tables 2 and 3 showing up in each others’ rows. Table 2 and 3 have different schemas.
So, assuming I had only 1 row in table 1, 3 rows in table 2, and 5 rows in table 3, I want to get back 3 + 5 = 8 rows.
I have tried joining these a number of ways. This is the last thing I tried, but it did not do what I am looking for.
SELECT *
FROM Payments p
left outer join Notices n on n.PaymentID = p.ID
left outer join Checks c on c.PaymentID = p.ID
where p.ID = 154;
Scott is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.