• Home
  • Billiards
  • Classic ASP
  • Browse Blog
    • Halifax
    • Internet
    • Internet Marketing
    • Programming
    • SEO
    • sitemap
    • Skateboarding
    • technology
      • Automation
    • travel
    • Web Development
    • Web Hosting
    • Website Management
    • wedding
  • Subscribe via RSS

SQL Full Outer Join Three Tables

December 6th, 2011  |  Published in Programming, Web Development




Here is some code to do a full outer join on three tables.

In the example, the three full outer joins are done on two columns , but it works just the same if you only have a single join column.


CREATE TABLE ZA (T CHAR(1), O CHAR(1))
CREATE TABLE ZB (T CHAR(1), O CHAR(1))
CREATE TABLE ZC (T CHAR(1), O CHAR(1))

INSERT INTO ZA (T, O) VALUES ('1', 'A')
INSERT INTO ZA (T, O) VALUES ('2', 'B')
INSERT INTO ZA (T, O) VALUES ('3', 'C')
INSERT INTO ZA (T, O) VALUES ('4', 'D')

INSERT INTO ZB (T, O) VALUES ('1', 'A')
INSERT INTO ZB (T, O) VALUES ('2', 'B')
INSERT INTO ZB (T, O) VALUES ('5', 'E')
INSERT INTO ZB (T, O) VALUES ('6', 'F')

INSERT INTO ZC (T, O) VALUES ('2', 'B')
INSERT INTO ZC (T, O) VALUES ('3', 'C')
INSERT INTO ZC (T, O) VALUES ('4', 'D')
INSERT INTO ZC (T, O) VALUES ('5', 'E')
INSERT INTO ZC (T, O) VALUES ('7', 'G')





SELECT 
	ISNULL(ISNULL(A.T, B.T), C.T),
	ISNULL(ISNULL(A.O, B.O), C.O)
	
FROM
	ZA A FULL OUTER JOIN 
	ZB B ON A.T = B.T AND A.O = B.O FULL OUTER JOIN 
	ZC C ON ISNULL(A.T, B.T) = C.T AND ISNULL(A.O, B.O) = C.O




DROP TABLE ZA
DROP TABLE ZB
DROP TABLE ZC

Leave a Response

Tags

1and1 adsense asp caribbean classic asp crowdsourcing CTR cuba Cueva de Pirata customer service database dominican republic forum management godaddy google Halifax hosting hotel ideagora Internet Linux MySQL objWmiService outsourcing php Pirates Cave plugin scripting scripts SEO Skateboarding sql travel Varadero vbs vbscript web browser web development wedding What is Crowdsourcing? wikipedia windows windows scripting winmgmts xp

Pages

  • About Robar’s Pages
    • Privacy Policy for robarspages.ca
  • Classic ASP Programming and Development
  • Gran Bahia Principe Wedding
  • YouTube Extension Plugins for WordPress

Categories

  • Automation
  • Halifax
  • Internet
  • Internet Marketing
  • Programming
  • SEO
  • sitemap
  • Skateboarding
  • technology
  • travel
  • Web Development
  • Web Hosting
  • Website Management
  • wedding

Recent Posts

  • HTTP_X_EAC_REQUEST
  • eZooms Bot User Agent
  • SQL Full Outer Join Three Tables
  • Classic ASP Data Caching for Performance
  • Comparing OLE DB and ODBC Connections

Recent Comments

  • AP on 1and1 Corporate Headquarters Phone Number
  • AJ on 1and1 Corporate Headquarters Phone Number
  • cordova on 1and1 Corporate Headquarters Phone Number
  • mike on 1and1 Corporate Headquarters Phone Number
  • David on Regex MM/YYYY Regular Expression for Credit Card Expiration Date
©2023 Robar's Pages
Sitemap and Table Of Contents