MySQL Tutorials - Herong's Tutorial Examples - v4.46, by Herong Yang
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
MySQL Introduction and Installation
Introduction of MySQL Programs
Perl Programs and MySQL Servers
Java Programs and MySQL Servers
Character Strings and Bit Strings
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
►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
Defining and Calling Stored Procedures
Variables, Loops and Cursors Used in Stored Procedures
System, User-Defined and Stored Procedure Variables
Storage Engines in MySQL Server
InnoDB Storage Engine - Primary and Secondary Indexes
Performance Tuning and Optimization
Installing MySQL Server on Linux