top of page
Search

SQL Joins

  • Mar 21, 2014
  • 1 min read

Note: The word Outer is optional

Join Type

Description

Example Code

Inner Join

Rows that are in both tables (by id)

select * from tblA

inner join tblB

on tblA.id=tblB.id

Full

All rows from both tables even if there isn't a match

select * from tblA

full outer join tblB

on tblA.id=tblB.id

Left

Rows from both tables but only where there isn't a match

select * from tblA

left outer join tblB

on tblA.id=tblB.id

where

tblA.id is null or tblB.id is null

Left

Rows in table A that do not have matching rows in table B based on criteria

select * from tblA

where not exists (

select * from tblB where tblA.id = tblB.Id and tblb.field1='Something'

)

Credits

Left Join

All rows from table A even if there isn't a matching row in table B

select * from tblA

left outer join tblB

on tblA.id=tblB.id

Left

Rows in table A that do not match a row in table B

select * from tblA

left outer join tblB

on tblA.id=tblB.id

where tblB.id is null

Right

All rows from table B even if there isn't a matching tow in table A

select * from tblA

right outer join tblB

on tblA.id=tblB.id

External Links

 
 
 

Recent Posts

See All
New AB Exams from Microsoft

Four new exams with related courses and the prefix AB were released by Microsoft during December 2025 and January 2026. These are summarized in the table below. Exam Study Guide Title Link to Course A

 
 
 

Comments


bottom of page