Professional Documents
Culture Documents
tables, and it is also called a Cartesian product. In the example above, one table
has two rows and the other one has three, so there are six rows in the result set:
c1 c2 c3
== == ==
1 1 7
1 1 8
1 1 9
2 1 7
2 1 8
2 1 9
The CROSS JOIN operator is the only one that doesnt allow unwanted rows to
be eliminated with the ON clause. Thats why its the simplest join operator, and
also why its the least useful: It usually returns too many rows. For example, a
CROSS JOIN of two ten-thousand-row tables would return one hundred million
rows.
SELECT parent.parent_key,
parent.data_1,
child.child_key,
child.parent_key
FROM parent INNER JOIN child ON parent.parent_key = child.parent_key
ORDER BY parent.parent_key,
child.child_key;