SQL Theory: Difference CROSS JOIN Vs CROSS APPLY

A CROSS JOIN will always join (combine) every row in table 1 with every row in table 2.  You can’t specify a condition on a cross join, even if you want to.

CROSS APPLY will join every row in table 1 with only rows with matching column values in table 2.  But, if you don’t specify any columns to do the matching on, every row automatically matches, which causes CROSS APPLY to produce the same result as a CROSS JOIN.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s