Understanding Inner Joins in SQL Server with more practical examples

It returns resultset only, if there is a match between both tables

Inner Join Diagram


INNER JOIN SYNTAX:

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

INNER JOIN EXAMPLE 1:

SELECT u.UserName,u.CountryName from users u inner join country c on u.countryid=c.countryid;

INNER JOIN EXAMPLE 2:

SELECT c.CustomerName,ord.OrderDate from Customers c INNER JOIN Orders ord ON c.Customerid=ord.Customerid

INNER JOIN EXAMPLE 3:

SELECT s.StudentName,c.CourseName from Students s INNER JOIN Course c ON s.Studentid = c.Studentid