Specifying Tables: The FROM Clause

The FROM clause is required in every SELECT statement involving data from tables or views. Use it to list the tables and views containing the columns included in the select list and in the WHERE clause. Separate multiple table or view names, with commas. The FROM clause uses this syntax:

SELECT select_list
FROM {table_name | viewname list} [(optimizer_hints)]

To simplify writing queries, you can give aliases to table names. Aliases are assigned in the FROM clause by specifying the alias after the table name. In the following example, the alias p is assigned to publishers:

SELECT p.pub_id, p.pub_name
FROM publishers p

Optional optimizer hints in the FROM clause allow you to customize locking for tables specified in the SELECT statement. For example, you can use the HOLDLOCK option to keep a shared lock in force until the completion of a transaction ¾ instead of releasing the lock as soon as the data is no longer needed. For details about the optimizer hints, see Optimizing Performance. Note that hints should be included inside parentheses so that they are not interpreted as an alias for a table.