blog post

FULL JOIN returns all matching records from both tables whether the other table matches or not.
FULL JOIN can potentially return very large datasets.
FULL JOIN and FULL OUTER JOIN are the same.

The SQL FULL JOIN syntax

The general syntax is:
SELECT column-names
  FROM table-name1 FULL JOIN table-name2 
    ON column-name1 = column-name2
 WHERE condition

The general FULL OUTER JOIN syntax is:
    SELECT column-names
  FROM table-name1 FULL OUTER JOIN table-name2 
    ON column-name1 = column-name2
 WHERE condition

SQL FULL JOIN Examples

Problem: Match all customers and suppliers by country

SELECT C.FirstName, C.LastName, C.Country AS CustomerCountry, 
       S.Country AS SupplierCountry, S.CompanyName
  FROM Customer C FULL JOIN Supplier S 
    ON C.Country = S.Country
 ORDER BY C.Country, S.Country

This returns suppliers that have no customers in their country,
and customers that have no suppliers in their country,
and customers and suppliers that are from the same country.

  • Share This Story


Pleas give your valuable comments to improve the contents.

about author

Atul kumar shukla


I'm Atul Kumar Shukla, working as a web developer.
Welcome to my Blog. This is my personal blog where i post my own questions and answers , articles about ASP.Net., SQL Server, HTML, CSS, Jquery and many more..

Visit Profile

Leave a comment

Name
E-mail
Url
Message

Get More Stuff
Subscribing to the TheOneblogs newsletter and get intersting stuff and updates to your email inbox.
Your Email

 

Style Switcher

Change Color

×! We use cookies to improve your user experience. More information