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

Code has been added to clipboard!

How to Use SQL INNER JOIN

Reading time 1 min
Published Aug 9, 2017
Updated Oct 10, 2019

SQL INNER JOIN Keyword: Main Tips

  • The INNER JOIN keyword selects the pair tables rows if there is a match between in two tables columns.
  • INNER JOIN acts the same as JOIN.

Syntax of SQL INNER JOIN

Selects information that has matching values in both tables.

Example
SELECT column_name(s)
FROM mytable1
INNER JOIN mytable2 ON mytable1.column_name = mytable2.column_name;
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 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

This is 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

SQL INNER JOIN: Examples

The next SQL statement will return all developers with orders:

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

Note: the columns are matching, the INNER JOIN keyword selects the two tables rows. Customers will NOT be listed, if there is a difference between the rows.

In this example we JOIN three tables: select all orders with developer and client information:

Example
SELECT Orders.ID, Developers.Name, Customers.Name
FROM ((Orders
INNER JOIN Developers ON Orders.ID = Developers.ID)
INNER JOIN Customers ON Orders.ID = Customers.ID);