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

SQL+Self+Join

Uploaded by

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

SQL+Self+Join

Uploaded by

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

SQL Self Join

SQL Self Join


SQL Self Join

self join
SQL Self Join

self join
applied when a table must join itself
SQL Self Join

self join
applied when a table must join itself
- if you’d like to combine certain rows of a table with other rows of the
same table, you need a self-join
INNER JOIN

Related column: dept_no


INNER JOIN

in a self-join statement, you will have to comply with the same logical and
syntactic structure
SQL Self Join

in a self-join statement, you will have to comply with the same logical and
syntactic structure
SQL Self Join

in a self-join statement, you will have to comply with the same logical and
syntactic structure
SQL Self Join

- the 2 tables will be identical to the table you’ll be using in the self-join
SQL Self Join

- the 2 tables will be identical to the table you’ll be using in the self-join
SQL Self Join

=
- the 2 tables will be identical to the table you’ll be using in the self-join
SQL Self Join

=
- the 2 tables will be identical to the table you’ll be using in the self-join
- you can think of them as virtual projections of the underlying, base table
SQL Self Join

=
- the self-join will reference both implied tables and will treat them as two
separate tables in its operations
SQL Self Join

=
- the data used will come from a single source, which is the underlying table
that stores data physically
INNER JOIN
INNER JOIN

M D
SQL Self Join

=
- using aliases is obligatory
SQL Self Join

e1 = e2

- using aliases is obligatory


SQL Self Join

e1 = e2

- these references to the original table let you use different blocks of the
available data
SQL Self Join

e1 = e2

- you can either filter both in the join, or you can filter one of them in the
WHERE clause, and the other one – in the join
SQL Self Join

emp_manager

e1 = e2

You might also like