Specifying tables with the from clause

The from clause is required in every select statement involving data from tables or views. Use it to list all the tables and views containing columns included in the select list and in the where clause. If the from clause includes more than one table or view, separate them with commas.

At most, a query can reference 50 tables and 46 worktables (such as those created by aggregate functions). The 50-table limit includes:

See the Reference Manual: Commands.

Table names can be 1 – 255 bytes long. You can use a letter, @, #, or _ as the first character. The characters that follow can be digits, letters, or @, #, $, _, ¥, or £. Temporary table names must begin either with “#” (pound sign), if they are created outside tempdb, or with “tempdb..”. Temporary table names cannot be longer than 238 bytes, as Adaptive Server adds an internal numeric suffix of 17 bytes to ensure that the name is unique. See Chapter 8, “Creating Databases and Tables.”

The full naming syntax for tables and views is always permitted in the from clause:

database.owner.table_name 
     database.owner.view_name 

However, the full naming syntax is required only if there is potential confusion about the name.

Tto save typing, you can assign table names correlation names. Assign the correlation name in the from clause by giving the correlation name after the table name, like this:

select p.pub_id, p.pub_name 
from publishers p 

All other references to that table (for example, in a where clause) must also use the correlation name. Correlation names cannot begin with a numeral.