🔥 $100K Hit! Where Will Bitcoin Go Next? Find Out Live!

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.
DataCamp
Pros
  • Easy to use with a learn-by-doing approach
  • Offers quality content
  • Gamified in-browser coding experience
  • The price matches the quality
  • Suitable for learners ranging from beginner to advanced
Main Features
  • Free certificates of completion
  • Focused on data science skills
  • Flexible learning timetable
Udacity
Pros
  • Simplistic design (no unnecessary information)
  • High-quality courses (even the free ones)
  • Variety of features
Main Features
  • Nanodegree programs
  • Suitable for enterprises
  • Paid Certificates of completion
edX
Pros
  • A wide range of learning programs
  • University-level courses
  • Easy to navigate
  • Verified certificates
  • Free learning track available
Main Features
  • University-level courses
  • Suitable for enterprises
  • Verified certificates of completion

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