Database Reference
In-Depth Information
Cross Joins
The simplest way of joining two or more tables together is by specifying more than one
table after the FROM keyword as follows:
SELECT columns
FROM
table1, table2, etc
However, that seldom produces the effect that you might expect. Try joining the Log table
to the webpage table as follows:
SELECT
*
FROM
log, webpage
Figure 7.2 shows the results of this join, called the cross join.
Can you see what this join has done? It is probably easier if you look at this on the screen
as it is difficult to show all of the rows in the figure. Look at how many rows the query has
returned. By selecting two tables, containing five and seven rows respectively, the query has
generated 35 rows as a result. This is because the cross join links every row in the Log table
with every row in the webpage table (5
7 = 35). If you scroll along the results you will see
that the contents of the rows of both tables are represented in each row of these results.
Now scroll across and look at all the columns that the query has returned. You will see
that each record has returned a row that has every column of every table specified in it. You
×
Figure 7.2
The cross join.
Search WWH ::




Custom Search