home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
sql
/
join.shr
< prev
next >
Wrap
Text File
|
1988-02-08
|
2KB
|
62 lines
JOINING TABLES (SHORT VERSION)
Often, the data we need exists in more than one table. In
order to extract the data, we need to select the appropriate
columns and join the tables. The type of join primarily
discussed is called a natural join but for the sake of brievity
I will just use the word "join" alone. Assume that we have the
following two tables:
THE PRODUCT TABLE THE MANUFACTURING TABLE
prod = table name manu = table name
code = product code code = product code
desc = product description mst = state of manufacture
defects = percent of defects
Our objective is to produce a report which contains the data in
the manufacturing table along with the product description. We
do this by referring to both tables in the "from" clause and
setting the common columns equal to each other. Since the
column named code exists in both tables, you must precede the
column name with the table name:
select manu.code, desc, mst, defects
from prod, manu
where prod.code = manu.code;
This select statement will display the same data as in the pm
table in the section on the select statement. The reason we
prefer to keep the data in separate tables has to do with data
normalization which is covered in the full documentation.
Details on joining are found in the full documentation.
JOIN-1