Joining Data: I. SQL Join Clauses
Joining Data: I. SQL Join Clauses
Joining Data: I. SQL Join Clauses
Joining Data
I. SQL Join Clauses
These are used to combine records from two (2) or more tables in a database based
on a common field/column.
It has different types depending on the tables used, the data output required, and the
way the tables are joined.
II. Inner Join
It is a join statement that returns rows where there is at least one match in both tables.
The primary key of one table must have a matching foreign key to the other table to
combine with.
III. Outer Join
It is considered as an extension of the inner join, but does not require each record in
the two (2) joined tables to have a matching record.
The joined table retains each record even if no other matching record exists.
It can further be subdivided into other types of joins depending on which table(s) one
retains the rows from (left, right, or both).
IV. Left, Right, and Full Join
A. The LEFT JOIN Statement
It returns all rows from the left table (the first table) even if there are no matches
on the right table (the second table).
B. The RIGHT JOIN Statement
It returns all rows from the right table (the second table) even if there are no
matches on the left table (the first table).
C. The FULL JOIN Statement
Both tables are secondary (or optional).
If rows are being matched in table A and table B, then all rows from table A are
displayed even if there is no matching row in table B, and vice versa.
References
Coronel, C., Crockett, K., and Rob, P. (2012). Database systems: Design, implementation &
management. USA: Cengage Learning EMEA
Singh, S. K. (2009). Database systems: Concepts, design and applications. India: Pearson
Education.
Adamski, J. and Pratt, P. (2012). Database management systems (7th ed.). USA: Cengage
Learning
Elmarsi, R. and Navathe, S. (2010). Fundamentals of database systems (6th ed.). Pearson
Education South Asia Pte. Ltd.
Rockoff, L. (2011). The language of SQL. Cengage Learning.
Korth, H., Silberschatz, A., and Sudarshan, S. (2011). Database system concepts (6th ed.). New
York. McGraw-Hill.
Study.com - Mathematical sets: Elements, intersections & unions (n.d.). Retrieved on March 23,
2017 at http://study.com/academy/lesson/mathematical-sets-elements-intersections-unions.html.