0% found this document useful (0 votes)
99 views2 pages

SQL Inner Join Explained with Example

SQL INNER JOIN clause is used to select data from 2 (or more) tables, at least one match in both tables.

Uploaded by

sqls666
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
99 views2 pages

SQL Inner Join Explained with Example

SQL INNER JOIN clause is used to select data from 2 (or more) tables, at least one match in both tables.

Uploaded by

sqls666
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

SQL INNER JOIN

SQL INNER JOIN clause is used to select data from 2 (or more) tables, at least one
match in both tables.

SQL INNER JOIN Clause Syntax

SELECT Table1.Column1, Table1.Column2, ... , 
Table2.Column1, Table2.Column2, ...  

FROM Table1  

INNER JOIN Table2  

ON [Link] = [Link]  

Note: SQL INNER JOIN is the default type of SQL JOIN. “JOIN” = “INNER JOIN”

SQL INNER JOIN Clause Example

Table: Employees

EmployeeId FirstName LastName Department Salary


203 Mazojys Fxoj Finance 78000
204 Jozzh Lnanyo Finance 45800
205 Syllauu Dfaafk Finance 57000
206 Gecrrcc Srlkrt Finance 62000

Table: Tickets

TicketID TicketNo EmployeeId


1 2349 203
2 2400 204
3 2438 205

Select all the employees with any tickets:

SELECT [Link]  
           , [Link]  
           , [Link]  
           , [Link]  

FROM Employees  
INNER JOIN Tickets  

ON [Link] = [Link]  
The result will look like:

EmployeeId FirstName LastName TicketNo


203 Mazojys Fxoj 2349
204 Jozzh Lnanyo 2400
205 Syllauu Dfaafk 2438

Note: The employee whose EmployeeId is 206 doesn’t have any records matched in the
table Tickets, so this employee will not in the result.

As mentioned above, “JOIN” = “INNER JOIN”, so, the following statement has the same
result:

SELECT [Link]  
           , [Link]  
           , [Link]  
           , [Link]  

FROM Employees  

JOIN Tickets  

ON [Link] = [Link]  

In most database systems, we can even write it shorter:

SELECT [Link]  
           , [Link]  
           , [Link]  
           , [Link]  

FROM Employees, Tickets  

WHERE [Link] = [Link]  

Ref: [Link]

SQL INNER JOIN

You might also like