Inner Join Usage in SQL

Itacen Sabacok | Aug 27, 2022

INNER JOIN keyword selects records that have matching values in both tables.

Here is the sample of Engineer table

id fullname title department manager
1 Eric Brown Software Engineer IT Frank Martin
2 Brandon Hart DevOps Engineer IT Justin Martin
3 Connor Langdon Software Engineer IT Lucas Scott

Here is the sample of Certificate table

id engineerid certificatename certificatedate
1 1 Docker Certified Associate 2020-05-05
2 2 Certified Kubernetes Administrator 2021-07-03

Here is the sample of Course table

id certid coursename courselink
1 1 Udemy https://www.udemy.com/
2 1 Pluralsight https://www.pluralsight.com/
3 2 Linuxfoundation https://training.linuxfoundation.org/

Examples / Outputs

1SELECT e.id, e.fullname, c.certificatename 
2FROM engineer AS e
3INNER JOIN certificate AS c
4ON e.Id=c.Engineerid;
engineerid fullname certificateName
1 Eric Brown Docker Certified Associate
2 Brandon Hart Certified Kubernetes Administrator

Join more than two Tables

1SELECT e.id, e.fullname "Full Name", 
2cert.certificatename "Certificate Name",
3co.coursename  "Course Name"
4FROM engineer AS e
5INNER JOIN certificate AS cert ON e.Id=cert.engineerid
6INNER JOIN course as co ON co.certid=cert.id;
id Full Name Certificate Name Course Name
1 1 Udemy https://www.udemy.com/course/docker-certified-associate/
2 1 Pluralsight https://www.pluralsight.com/
3 2 Linuxfoundation https://training.linuxfoundation.org/certification/ certified-kubernetes-administrator-cka/