0% found this document useful (0 votes)
3 views

Aggregates

The ON clause specifies how rows from two tables are related during a join, typically matching foreign keys to primary keys, but allowing for more complex relationships. The document outlines various join types, including INNER JOIN, OUTER JOIN (LEFT, RIGHT, FULL), NATURAL JOIN, and CROSS JOIN, each serving different purposes in data retrieval. Additionally, it mentions the use of aggregate queries to generate summaries from the data using aggregate functions.

Uploaded by

Venkat Kv
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Aggregates

The ON clause specifies how rows from two tables are related during a join, typically matching foreign keys to primary keys, but allowing for more complex relationships. The document outlines various join types, including INNER JOIN, OUTER JOIN (LEFT, RIGHT, FULL), NATURAL JOIN, and CROSS JOIN, each serving different purposes in data retrieval. Additionally, it mentions the use of aggregate queries to generate summaries from the data using aggregate functions.

Uploaded by

Venkat Kv
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

The ON Clause

The ON clause is used to describe which rows from one table are joined to which
rows from the other, by declaring which columns from each should match.
The most obvious join is from the child table’s foreign key to the parent table’s
primary key. More complex joins are possible.
You can also create ad hoc joins which match columns which are not in a fixed
relationship.
Join Types
The default join type is the INNER JOIN. The INNER is presumed when no join type
is specified:
An INNER JOIN results only in child rows for which there is a parent. Rows
with a NULL foreign key are omitted.
An OUTER JOIN is an INNER JOIN combined with unmatched rows. There
are three types of OUTER JOIN:A LEFT or RIGHT join includes unmatched rows
from one of the joined tables.
A FULL join includes unmatched rows from both tables.
A NATURAL join matches two columns with identical names and doesn’t
require an ON clause. It is particularly useful in joining one-to- one tables. Not all
DBMSs support this.

There is also a CROSS JOIN, which combines every row in one table with every
row in the other. It’s not generally useful, but can be handy when you cross join
with a single row of variables.
Aggregates
Instead of just fetching simple data from the database tables, you can generate
various summaries using aggregate queries. Aggregate queries use one or more
aggregate functions and imply some groupings of the data.

You might also like