You can create a view combining information from more than one table
by selecting more than one table in the work area of the New View window.
You can create a simple view from more than one table by selecting the columns
that you want to include from different tables and clicking
OK. However,
this example shows how to create a view that joins information from two different
tables and returns only those rows that you want to see, much like using a
WHERE clause.
In this example, you create a view that contains only those
item numbers for suppliers that can supply an item at lower cost than the
current unit cost. This requires selecting ITEM_NUMBER and UNIT_COST
from the INVENTORY_LIST table and joining them with SUPPLIER_NUMBER and SUPPLIER_COST
from the SUPPLIERS table. A WHERE clause is used to limit the number of rows
returned.
Note: You can view the SQL used to create this view by selecting Show
SQL. You can also edit the SQL by selecting Edit SQL.
Edit SQL starts Run SQL Scripts, where you can edit your SQL statement. Be
aware, however, that if you change the SQL, you will need to run the statement
from Run SQL Scripts rather than returning to the New View window. If you
return to the New View window, your changes are not saved.
To display
the contents of this new view, right-click LOWER_COST and select View
Contents. The rows that you see through this view are only those
rows that have a supplier cost that is less than the unit cost.
ITEM_NUMBER |
UNIT_COST |
SUPPLIER_NUMBER |
SUPPLIER_COST |
153047 |
10.00 |
9988 |
8.00 |
153047 |
10.00 |
2424 |
9.00 |
229740 |
1.50 |
1234 |
1.00 |
303476 |
2.00 |
3366 |
1.50 |
073956 |
20.00 |
3366 |
17.00 |