Black friday

Save big!

All courses under $5 - for a limited time!

Code has been added to clipboard!

How to Combine Table Rows Using SQL JOIN

Reading time 1 min
Published Aug 11, 2017
Updated Oct 3, 2019

SQL Joins: Main Tips

  • SQL joins are used to combine more than one tables rows.
  • SQL INNER JOIN is the most common JOIN. An SQL INNER JOIN returns all multiple tables rows where the join condition is met.

SQL Join: Types

  • LEFT JOIN: It returns the left table rows and right table rows which matched.
  • RIGHT JOIN: It returns the right table rows, and left table rows which matched.
  • INNER JOIN: It returns all rows when there is the same record in BOTH tables.
  • FULL OUTER JOIN: It returns all rows when the same record occurs in BOTH tables.
Theory is great, but we recommend digging deeper!

Demo Database

This is a demo example from the "Orders" table in the database:

ID Customer_ID Employee_ID
20408 2 7
20409 2 5
85471 1 3
75864 5 8

This is a demo example from the "Developers" table in the database:

ID Name City Country
1 Tom Kurkutis New York USA
2 Ana Fernandez London UK
3 Antonio Indigo Paris France
4 Aarav Kaelin Delhi India
5 Andrew Tumota Miami USA

INNER JOIN: Example

Example
SELECT Customer_orders.ID, Developers.Name
FROM Customer_orders
INNER JOIN Developers ON Customer_orders.employee_id = Developers.ID;

The result table looks like this:

ID Name Date
1509 Tom Kurkutis 8/18/2017
1510 Andrew Tumota 12/19/2016
1511 Andrew Tumota 01/25/2017