FROM clause
The FROM
clause indicates the tables that are used in the SELECT
statement. The format is:
FROM table_name [table_alias] [, table_name [table_alias]]
table_name
is the name of a table in the current database. The table name must begin with an alphabetic character. If the table name begins with other than an alphabetic character or contains a period (.), enclose it in double quotation marks (quoted identifier).
table_alias
can be used to give the table a more descriptive name, to abbreviate a longer table name, or to include the same table in the query more than once (for example, in self-joins).
Field names begin with an alphabetic character. If the field name begins with other than an alphabetic character or contains a period (.), enclose it in double quotation marks (quoted identifier).
The ExecuteSQL
statement for the field named _LASTNAME
is:
SELECT "_LASTNAME" from emp
Field names can be prefixed with the table name or the table alias.
Given the table specification FROM employee E
, you can refer to the LAST_NAME
field as E.LAST_NAME
. Table aliases must be used if the SELECT
statement joins a table to itself.
SELECT * FROM employee E, employee F WHERE E.manager_id = F.employee_id
The equal sign (=) includes only matching rows in the results.
If you are joining more than one table, and you want to discard all rows that don’t have corresponding rows in both source tables, you can use INNER JOIN
.
SELECT *
FROM Salespeople INNER JOIN Sales_Data
ON Salespeople.Salesperson_ID = Sales_Data.Salesperson_ID
If you are joining two tables, but you don’t want to discard rows of the first table (the "left" table), you can use L
EFT OUTER JOIN
.
SELECT *
FROM Salespeople LEFT OUTER JOIN Sales_Data
ON Salespeople.Salesperson_ID = Sales_Data.Salesperson_ID
Every row from the "Salespeople" table will appear in the joined table.
Notes
-
RIGHT OUTER JOIN
is not currently supported. -
FULL OUTER JOIN
is not currently supported.