This is the thirtieth part of the SQLxD series. For your convenience you can find other parts in the table of contents in Part 1 – XML Transformation

We mentioned the natural join a few times and it finally the part when we implement it. Here we go:

First, we compare guid collection lengths. This is for checking whether it is possible for the relations to be in parent-child relation. Next, we find candidate for parent and start comparing guids. If all guids match then we can join rows.

And here are tests for this mechanism:

This concludes our JOIN journey. Next time we are going to implement grouping.