0% found this document useful (0 votes)
12 views4 pages

Visual Guide to SQL Joins

The document explains different types of SQL joins including inner joins, full outer joins, left outer joins, and cross joins. It uses tables and Venn diagrams to visually demonstrate how each join combines records from two tables based on matching fields.

Uploaded by

dsunismine
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 PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views4 pages

Visual Guide to SQL Joins

The document explains different types of SQL joins including inner joins, full outer joins, left outer joins, and cross joins. It uses tables and Venn diagrams to visually demonstrate how each join combines records from two tables based on matching fields.

Uploaded by

dsunismine
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 PDF, TXT or read online on Scribd

Joins

AVisualExplanationofSQLJoins
[Link],andTableBisontheright. We'llpopulatethemwithfourrecordseach.

Let'sjointhesetablesbythenamefieldinafewdifferentwaysandseeifwecangeta conceptualmatchtothoseniftyVenndiagrams.

InnerjoinproducesonlythesetofrecordsthatmatchinbothTableAandTableB.

FullouterjoinproducesthesetofallrecordsinTableAandTableB,withmatchingrecords [Link],themissingsidewillcontainnull.

LeftouterjoinproducesacompletesetofrecordsfromTableA,withthematchingrecords (whereavailable)[Link],therightsidewillcontainnull.

ToproducethesetofrecordsonlyinTableA,butnotinTableB,weperformthesameleftouter join,thenexcludetherecordswedon'twantfromtherightsideviaawhereclause.

ToproducethesetofrecordsuniquetoTableAandTableB,weperformthesamefullouter join,thenexcludetherecordswedon'twantfrombothsidesviaawhereclause.

There'salsoacartesianproductorcrossjoin,whichasfarasIcantell,can'tbeexpressedas aVenndiagram:

Thisjoins"everythingtoeverything",resultingin4x4=16rows,farmorethanwehadinthe [Link],youcanseewhythisisaverydangerousjointorunagainst largetables.

You might also like