Database Tutorial

Course Tutorial Site

Site Admin

Cross Join

with 2 comments

The principal join is a CROSS JOIN, which matches every row in one table against every row in another. This is an unfiltered join. The other join types start with this concept and filter the result set.

Another way to describe an CROSS JOIN is as a Cartesian Product, which is a combination of two sets where each row in one is matched to each row in another. The formula multiplies the sets, which means every ordered pair of (x,y) is unique. Each element x is an element (∈) in set A, and (∧) each element y is an element (∈) in set B. The ordered result set of (x,y) is not equal to the ordered result set of (y,x).

The CROSS JOIN may contain an intersection of rows because the ordered pair of (x,y) is the ordered pair of rows from the table on the left, or A, and they are matched against the rows from the table on the right, or B. Those elements (rows) in A that share an attribute (column) value with an attribute (column) value in an element (or row) from B become the intersection of a join. The intersection is also known as the INNER JOIN of the tables.

Written by michaelmclaughlin

January 17th, 2010 at 10:25 pm

Posted in

2 Responses to 'Cross Join'

Subscribe to comments with RSS or TrackBack to 'Cross Join'.

  1. While looking at this, trying to understand HOW to do CROSS JOINS, it is more confusing trying to learn php to get help with the SQL. The basic concept is very easy to understand, but knowing how to implement it is not. I therefore suggest that you use MySQL or ORACLE examples in all of the JOIN sections. Otherwise those of us who have not taken php classes can still understand what you are striving to teach us.

    Tyler

    23 Feb 11 at 5:21 pm

  2. Tyler, the PHP code is an example of how the same type of problem is solved using imperative programming languages.

    michaelmclaughlin

    22 Oct 14 at 2:31 am

Leave a Reply