Part 9 Difference between inner join and left join

Поделиться
HTML-код
  • Опубликовано: 8 сен 2024
  • Link for all dot net and sql server video tutorial playlists
    / kudvenkat
    Link for slides, code samples and text version of the video
    csharp-video-tu...
    Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our RUclips channel. Hope you can help.
    / @aarvikitchen5572
    This is one of the very common sql server interview question. Different JOINS in SQL Server are discussed in detail in Part 12 of SQL Server tutorial for beginners video series.
    Let's understand the difference with an example.
    INNER JOIN returns only the matching rows between the tables involved in the JOIN. Notice that, Pam employee record which does not have a matching DepartmentId in departments table is eliminated from the result-set.
    SELECT EmployeeName, DepartmentName
    FROM Employees
    INNER JOIN Departments
    ON Employees.DepartmentID = Departments.DepartmentID
    LEFT JOIN returns all rows from left table including non-matching rows. Notice that, Pam employee record which does not have a matching DepartmentId in departments table is also included in the result-set.
    SELECT EmployeeName, DepartmentName
    FROM Employees
    LEFT JOIN Departments
    ON Employees.DepartmentID = Departments.DepartmentID
    In general there could be several questions on JOINS in a sql server interview. If we understand the basics of JOINS properly, then answering any JOINS related questions should be a cakewalk.
    What is the difference between INNER JOIN and RIGHT JOIN
    INNER JOIN returns only the matching rows between the tables involved in the JOIN, where as RIGHT JOIN returns all the rows from the right table including the NON-MATCHING rows.
    What is the difference between INNER JOIN and FULL JOIN
    FULL JOIN returns all the rows from both the left and right tables including the NON-MATCHING rows.
    What is the Difference between INNER JOIN and JOIN
    There is no difference they are exactly the same. Similarly there is also no difference between
    LEFT JOIN and LEFT OUTER JOIN
    RIGHT JOIN and RIGHT OUTER JOIN
    FULL JOIN and FULL OUTER JOIN

Комментарии • 47