SQL Left Join - Left Join in SQL



SQL Left JOIN

  • The LEFT JOIN keyword retrieves all records from the left table (table1) and the corresponding records from the right table (table2). If there's no match, the result includes 0 records from the right side.

Syntax

    SELECT column_name(s)
    FROM table1;
    LEFT JOIN table2;
    ON  table1.column_name = table2.column_name;
    

Database

  • Here is a portion from the "Wikitechy" table:
table -Wikitechy

  • Here is an excerpt from the " Student Detail " table:
table-student-details

Example

SELECT tbl_Wikitechy.Student_Name, tbl_Student_Detail.Student_Id
FROM tbl_Wikitechy
LEFT JOIN tbl_Student_Detail
ON  tbl_Wikitechy.Student_Id = tbl_Student_Detail.Student_Id
ORDER BY  tbl_Wikitechy.Student_Name;

Output

sql-left-join


Related Searches to SQL Left Join - Left Join in SQL