JOIN

SQL JOIN Keyword

The JOIN clause combines rows from two or more tables based on a related column between them.

Tutorials dojo strip

SQL INNER JOIN Example

This query returns records from both Patients and Appointments tables where there is a matching patient_id.

SQL

SQL LEFT JOIN Example

This query returns all records from Doctors, along with matching Appointments, if any.

SQL

SQL RIGHT JOIN Example

This query retrieves all doctor_id values from the Doctors table and any matching appointment_id from the Appointments table, including doctors who do not have any appointments.

SQL

Note: This code does not work in SQLite or the TechKubo playground.


SQL FULL OUTER JOIN Example

This query retrieves all first_name values from the Patients table and all appointment_id values from the Appointments table, including patients without appointments and appointments without matching patients.

SQL

Note: This code does not work in SQLite or the TechKubo playground.

SQL JOIN Labs

Tutorials dojo strip