So I'm trying to write a query which is going to combine values from 4 tables. Three of those tables will be combined using Inner Joins. However, the fourth table must be combined used a left join as there may or may not be an index for a record in that table. Here's my query (well, a simplified version of it, anyway) using only inner joins:
What I'd like to do is something similar to the following:
Unfortunately, that doesn't seem to be valid SQL and I'm no SQL expert to figure out the best way to go about this.
The trick here is that a.YetAnotherForeignKey may be null. If it is not null, I want to pull the information from "additionalTable". If it is, that's just fine.
Anyone have a good way to do this in a single query? I can handle inner joins and I can handle left joins, but I can't say I've ever tried to put the two together quite like this.