FROM CLAUSE

  • The FROM clause lets a user sepcify a table or list of tables, which act as the source for a SELECT Statement.
  • An alias can be specifed for each of the listed tables in the FROM clause.
  • A Type can be specified for the Join between the two tables. This helps filter unwanted tuples. All join types except Cross Join have an implicit condition associated to it.

Syntax:

FromClause ::= FROM TableReference ( "," TableReference )* 

TableReference ::= ( SingleTable 
                     | CrossJoin
                     | QualifiedJoin
                     | NaturalJoin
                     | UnionJoin
                     )                         

CrossJoin ::= TableReference CROSS JOIN SingleTable

QualifiedJoin ::= TableReference [ JoinType ] JOIN              
                   TableReference JoinSpecification

NaturalJoin ::= TableReference NATURAL 
                  [ JoinType ] JOIN SingleTable

UnionJoin ::= TableReference UNION JOIN SingleTable

JoinSpecification ::=  JoinCondition | JoinColumns

JoinCondition ::= ON [[SearchCondition][SearchConditon]]

JoinColumns ::= USING "(" ( ColumnName )+ ")"

JoinType ::= INNER | ( ( LEFT | RIGHT | FULL ) [ OUTER ] ) 

SingleTable ::= TableName [ [ AS ] TableAlias ] 

Join Types with Examples:

Also Read:

TableName, TableAlias, ColumName