Fujitsu J2X0-1634-01EN Computer Accessories User Manual


 
[Figure: Table derived when two table names are specified in a FROM clause]
If two table names are specified in a FROM clause, the table derived from the FROM clause contains all columns and
rows in the two specified tables. This is called the expanded direct product of the table. In the same way, if three or
more tables names are specified in the FROM clause, the derived table contains all columns and rows in the specified
tables. In other words, the number of columns that results is the summation of the number of columns in the specified
tables. The row count is the product of the row counts of the specified tables. The sequence of columns in the derived
table is the sequence of columns in each table in the order in which the tables were specified.
5.2 Specifying Conditions to Join Tables
The expanded direct product derived from specifying multiple tables in a FROM clause combines all rows from the
specified tables, although many of the rows may contain insignificant data. When this data is processed by an
application program, all the rows are fetched, but the program only processes rows containing significant data.
Because a large number of rows are fetched, processing is not very efficient. So, in addition to joining tables, data
must be narrowed down to just significant data. To do so, specify a condition to join tables in the WHERE clause of the
table expression. The following is an example of specifying conditions in the WHERE clause:
Example 1:
In this example, the data that joins the two tables TBL1 and TBL2 in the example in Figure: Table
derived when two table names are specified in a FROM clause is specified as values for column COLA
and column COLZ.
SELECT ... FROM SCM.TBL1, SCM.TBL2 WHERE COLA = COLZ
58