Skip to main content
Learning DUB

The FROM clause specifies the tables, views, derived tables, and joined tables used in SELECT, UPDATE, and DELETE statements. The FROM clause is used to list all the tables and views containing columns included in the SELECT list and in the wWHERE clause.

Where to use the FROM Clause

The FROM clause is required in every SELECT statement in which data is being retrieved from tables or views. The table or view names can be aliased using the AS clause.
The FROM clause can also contain JOIN specifications, which define the specific path used in navigating from one table to another. These are qualified by join conditions specified in the ON clause.
The FROM clause is also used on the DELETE and UPDATE statements to define the tables that are modified.

USE pubs
SELECT type, AVG(price)
FROM titles
WHERE royalty = 10
GROUP BY type

Here is the result set:
**
Here is the result set:
Grouping Rules you must know

1. Every non-aggregate column that appears in the SELECT clause must also appear in the GROUP BY clause.
2. You may not use aliases in the HAVING clause. MySQL allows usage of aliases in the HAVING clause, but you may want to avoid this to keep your code as cross-database compatible as possible.
3. You may use aliases in the ORDER BY clause.
4. To filter rows based on aggregate functions, use the HAVING clause.
5. You should declare column aliases for any calculated fields in the SELECT clause.
6. You may not use aggregate functions in the WHERE clause.

///////////////////////////////////////////////

Related Content

Scroll to Top