FROM
Top  Previous  Next

Starting with all the tables, views, rows, and columns in the database, this clause specifies one or more tables or views from which you want data.

sel_from

Options

,

Indicates that this part of the command is repeatable.

corr_name

A correlation name is an alias or nickname for a table. It lets you refer to the same table twice in one command, use a shorter name, and explicitly refer to a column when referring to the same column if that column appears in more than one table.

tblview

A table or view containing one or more columns named in the command clause.

About the FROM Clause

The FROM clause names one or more tables and/or views from which the information is used in a SELECT command or other command. It is one of the two REQUIRED portions of a SELECT statement. The other required portion being the column listing. Some other commands that may use a FROM clause include TALLY, COMPUTE and CHOOSE.

Examples

The following command selects all columns from the transmaster table in the R:BASE sample database, concomp.

SELECT * FROM transmaster

The result of this command appears in the following table. The transid column is the primary key for this table; that is, transid contains a unique value for each row in the table. Columns that are not primary keys can have the same value in more than one row. The result shown here is used in the discussions of other SELECT clauses later in this section.

transid
custid
empid
transdate
netamount
freight
4760
100
133
01/02/94
$32,400.00
$324.00
4780
105
160
01/08/94
$9,500.00
$95.00
4790
104
129
01/09/94
$6,400.00
$64.00
4795
101
102
01/11/94
$176,000.00
$1,760.00
4800
105
160
02/22/94
$194,750.00
$1,947.50
4865
102
129
02/22/94
$34,125.00
$341.25
4970
103
131
02/23/94
$152,250.00
$1,522.50
4975
101
102
02/26/94
$87,500.00
$875.00
4980
101
102
02/27/94
$22,500.00
$225.00
5000
101
102
02/28/94
$40,500.00
$405.00
5010
107
131
03/02/94
$108,750.00
$1,087.50
5015
103
131
03/05/94
$80,500.00
$805.00
5050
104
129
03/06/94
$56,250.00
$562.50
5060
101
102
03/07/94
$57,500.00
$575.00
5065
106
160
03/13/94
$140,300.00
$1,403.00
5070
104
129
03/14/94
$95,500.00
$955.00
5075
102
129
03/15/94
$155,500.00
$1,555.00
5080
100
133
03/19/94
$88,000.00
$880.00
5085
107
131
03/18/94
$130,500.00
$1,305.00
5045
100
102
09/26/94
$3,060.00
$30.60
5046
101
165
09/27/94
$3,060.00
$30.60
5047
102
167
09/27/94
$3,830.00
$38.30
5048
103
133
-0-
$12,740.00
$127.40
5049
102
165
04/21/94
$26,310.00
$263.10


When a column appears in more than one table, enter the table name and a period preceding each column name to specify the column you want. For example:

SELECT transmaster.transid, transmaster.netamount,+
transdetail.model FROM transmaster, transdetail +
WHERE transmaster.transid = transdetail.transid

Or, you can assign a correlation name to a table. The following command is equivalent to the previous example:

SELECT t1.transid, t1.netamount, t2.model +
FROM transmaster t1, transdetail t2 +
WHERE t1.transid = t2.transid

In this SELECT command, the FROM clause assigns correlation names to the transmaster and transdetail tables. Because the transid column appears in both tables, the correlation names, t1 and t2, clarify which table each column is from.

Because R:BASE processes the FROM clause first, you must use correlation names, if you have assigned them, throughout the SELECT command.