LEFT JOIN command combines matching rows with rows from the left-side table.
SELECT column_name(s) FROM table_1 LEFT JOIN table_2 ON table_1.column_name = table_2.column_name;
Every row in the left table is returned in the result set. If the join condition is not met, then
NULL values are used to fill in the columns from the right table.
To create a result set of every row in the
students table combined with the
transfer_data table where student IDs match. And if the join condition is not met, then
NULL values are used to fill in the columns from the
SELECTstudents.first_name,students.last_name,students.overall_gpa,transfer_data.overal_gpaFROM studentsLEFT JOIN transfer_dataON students.student_id = transfer_data.student_id;
The result set will only include last name, first name, and both GPAs.
Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.
Learn SQL on Codecademy
Analyze Data with SQLLearn to analyze data with SQL and prepare for technical interviews.
Includes 8 Courses
Design Databases With PostgreSQLLearn how to create and optimize a database from scratch using PostgreSQL
Includes 5 Courses