ASA Getting Started
Selecting Data from Multiple Tables
One of the tables in the sample database is sales_order, which lists the orders placed to the company. Each order has a sales_rep column, containing the employee ID of the sales representative responsible for the order. There are 648 rows in the sales_order table and 75 rows in the employee table.
The cross product join is a simple starting point for understanding joins, but not very useful in itself.
List all data in the employee and sales_order tables
In Interactive SQL, type the following in the SQL Statements pane and press F5 to execute the statement.
SELECT * FROM sales_order CROSS JOIN employee
The results of this query, which appear on the Results tab in the Interactive SQL Results pane, match every row in the employee table with every row in the sales_order table. Since there are 75 rows in the employee table and 648 rows in the sales_order table, there are 75 × 648 = 48,600 rows in the result of the join. Each row consists of all columns from the sales_order table followed by all columns from the employee table. This join is called a full cross product.
Subsequent sections describe how to construct more selective joins. The more selective joins can be thought of as applying a restriction to the cross product table.
For more information, see Cross joins.