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;

Table of Contents

 About This Book

 Introduction of SQL

 MySQL Introduction and Installation

 Introduction of MySQL Programs

 PHP Programs and MySQL Server

 Perl 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 - Operation to Join Two Tables

 JoinTable.sql - Example of Join Tables

 WHERE Clause of a SELECT Statement

 ORDER BY Clause of a SELECT Statement

 GROUP BY Clause of a SELECT Statement

 Window Functions for Statistical Analysis

 Use Index for Better Performance

 Transaction Management and Isolation Levels

 Locks Used in MySQL

 Defining and Calling Stored Procedures

 Variables, Loops and Cursors Used in Stored Procedures

 System, User-Defined and Stored Procedure Variables

 MySQL Server Administration

 Storage Engines in MySQL Server

 InnoDB Storage Engine - Primary and Secondary Indexes

 Performance Tuning and Optimization

 Bulk Changes on Large Tables

 MySQL Server on macOS

 Installing MySQL Server on Linux

 Connection, Performance and Second Instance on Linux

 Archived Tutorials

 References

 Full Version in PDF/EPUB