Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.
The FROM clause is required in every SELECT statement involving data from tables, views, or stored procedures.
The FROM clause can include JOIN conditions linking two or more tables, and can include joins to other queries (derived tables). For information on these features, see Joins: Retrieving Data from Several Tables.
In the FROM clause, the full naming syntax for tables and views is always permitted, such as:
SELECT select-list FROM owner.table-name;
Qualifying table, view, and procedure names is necessary only when the object is owned by a user ID that is not the same as the user ID of the current connection, or is not the name of a group to which the user ID of the current connection belongs.
You can give a table name a correlation name to save improve readability and save entering the full table name each place it is referenced. You assign the correlation name in the FROM clause by entering it after the table name, like this:
SELECT d.DepartmentID, d.DepartmentName FROM Departments d;
When a correlation name is used, all other references to the table, for example in a WHERE clause, must use the correlation name, rather than the table name. Correlation names must conform to the rules for valid identifiers.
For more information about the FROM clause, see FROM clause.
The most common elements in a FROM clause are table names. It is also possible to query rows from other database objects that have a table-like structure—that is, a well-defined set of rows and columns. In addition to querying from tables and views, you can use derived tables (which are SELECT statements) or stored procedures that return result sets.
For example, the following query operates on the result set of a stored procedure.
SELECT * FROM ShowCustomerProducts( 149 );
For more information, see FROM clause.