Full Outer Join (More Than Two Tables)

I'm not even sure myself if this makes sense but can you join more than two tables with the new FULL outer join syntax.

For example if I have three tables can I join all three hoping to return all rows on all three tables only matching rows where the join condition is satisfied.

If this is possible, or even logical, give a code example.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Nick UpsonPrincipal Operations EngineerCommented:
"only matching rows where the join condition is satisfied." - this requires only an inner join between the tables

taking a 2 table example, customers and invoices, inner join them and get a list of all invoices that have a valid customer (or all customers that have a valid invoice - it's the same) left/right outer join them and get either all customers with their invoices, if they have any, or all invoices with a valid customer, full outer join will list all customers and all invoices, showing where they link
Haven't tried it, but I don't see any reason why full outer join across three tables wouldn't work. In reality, it's just two successive full outer joins:  Table1 full outer join table2 produces a result set and then full outer join that result set to table3.  

The result of a full outer join is the same as inner joining two tables then adding the rows in each table that do not have a matching row in the other table.  Columns from the missing table are represented by nulls.  

For example:



AlbumID  SongID
---------   --------
a1           s1
a2           s1
a2           s2  

Select * from tblSong as s
full outer join tblRelease as r on s.songID = r.SongID
full outer join tblAlbum   as a on a.albumID = r.AlbumID

s.songid       r.songid      r.albumid       a.albumID
---------       ---------       ----------        -----------
s1               s1               a1                 a1
s1               s1               a2                 a2
s2               s2               a2                 a2
s3               null             null               null
null             null             null                a3


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.