Difference between revisions of "Self-Joins"
Jump to navigation
Jump to search
(Created page with "'''Self Joins are used when a table must be joined to itself to retrieve the data you need. Table aliases are required in the FROM clause to perform self-join''' #Select C...") |
|||
Line 1: | Line 1: | ||
'''Self Joins are used when a table must be joined to itself to retrieve the data you need. Table aliases are required in the FROM clause to perform self-join''' | '''Self Joins are used when a table must be joined to itself to retrieve the data you need. Table aliases are required in the FROM clause to perform self-join''' | ||
SELECT r.firstname, r.lastname, r.referred, c.lastname "Referred" | |||
FROM customers c, customers r | |||
WHERE c.referred = r.customer#; | |||
[[#Select Command|Back To Top]]-[[Main_Page| Home]] - [[Oracle_SQL|Category]] | [[#Select Command|Back To Top]]-[[Main_Page| Home]] - [[Oracle_SQL|Category]] |
Revision as of 00:40, 24 October 2017
Self Joins are used when a table must be joined to itself to retrieve the data you need. Table aliases are required in the FROM clause to perform self-join
SELECT r.firstname, r.lastname, r.referred, c.lastname "Referred" FROM customers c, customers r WHERE c.referred = r.customer#;