FROM Clause of a SELECT Statement

A tutorial example is provided on how to use the FROM clause to provide tables, filters, aggregations and sorting order to SELECT statements.

The goal of the FROM clause is to define a single table or a set of multiple tables, filters, aggregations and sorting order for the SELECT statement. Its generic syntax is:

FROM table_reference [WHERE clause] [GROUP BY clause] [ORDER BY clause]

where:

The syntax for "table_reference" has different forms depending how the logical table is defined.

1. A real table - the base table is the specified real table.

FROM table_name

2. A query table - the base table is the output table of a select statement:

FROM (SELECT statement)

3. A join table - the base table is the output table of a join operation of two real, query or join tables.

FROM table_reference join_operation table_reference [join_condition]

where:

Sample select statements with FROM clause:

SELECT ID, Login, Email FROM User;
SELECT Price, Quantity, ROUND(Price*Quantity) FROM Sales;

Last update: 2015.

Table of Contents

 About This Book

 Introduction of SQL

 MySQL Introduction and Installation

 Introduction of MySQL Programs

 Perl Programs and MySQL Servers

 PHP Programs and MySQL Servers

 Java Programs and MySQL Servers

 Datatypes and Data Literals

 Operations and Expressions

 Character Strings and Bit Strings

 Commonly Used Functions

 Table Column Types for Different Types of Values

 Using DDL to Create Tables and Indexes

 Using DML to Insert, Update and Delete Records

Using SELECT to Query Database

 SELECT Statements

FROM Clause of a SELECT Statement

 JOIN -Operations to Join Two Tables

 JoinTable.sql - Example of Join Tables

 WHERE Clause of a SELECT Statement

 GROUP BY Clause of a SELECT Statement

 ORDER BY Clause of a SELECT Statement

 Transaction Management and Isolation Levels

 Locks Used in MySQL

 Defining and Calling Stored Procedures

 Variables, Loops and Cursors Used in Stored Procedures

 Outdated Tutorials

 References

 PDF Printing Version