Datasheet

useful in different circumstances. Briefly, the types of join you can perform are as follows (don’t worry
too much about these definitions at this stage — they will be explained in more detail shortly):
Cross join: Each row in table A is joined to each row in table B.
Inner join: Rows in table A and table B are joined according to the data contained in rows and
the criteria you choose to compare these rows by. Rows may be excluded from the result set if
no join is possible.
Outer join: Similar to an inner join, but rows that would otherwise be excluded may be included
in the result set depending on the exact specification of the join.
Understanding Cross Joins
The easiest of these joins to explain is the cross join, although you will probably find it the least useful.
The syntax of using a cross join between, say, tables called
TableA and TableB, is to specify the from
clause of a query as follows:
FROM TableA CROSS JOIN TableB
Or using the simpler syntax:
FROM TableA, TableB
The full select statement includes other clauses much like queries over a single table, including column
specifications and filters. For example:
SELECT * FROM Product, ProductCategory WHERE CategoryName = ‘Things’
Using actual data will help you understand the query better. Let’s say that the Product and
ProductCategory tables contain data as shown in Figures 1-5 and 1-6.
Figure 1-5: Product table contents
Figure 1-6: ProductCategory table contents
Without considering the where clause for now, a cross join between these two tables results in the six
rows shown in Figure 1-7. (Some of the GUID columns are truncated in this figure to save space.)
21
Database Fundamentals
44063c01.qxd:WroxBeg 9/12/06 10:31 PM Page 21