SQL Join Types: Cross Join

Tables

Table 1: Foods

ItemId

ItemName

ItemUnit

CompanyId

1

Mixing

Pcs

16

2

Bananas

Pcs

15

3

Munching

Pcs

17

Basmati Rice 

Pcs

15

Cheese Cake

Pcs

18

6

Brie Cheese

Pcs

NULL

7

Salt & Pepper Chips

Pcs

15

Table 2: Orders

CompanyId

CompanyName

CompanyCity

18

Kellog

Florida

15

Nestle

Paris

16

Trader Joe

Denver

17

Wegmans

New York

19

Bits and Bytes

Buenos Aires

Note: There is no order in which the CustomerID = 1 (Alfreds Futterkiste).

Query

SELECT Foods.ItemName, Foods.ItemUnit, Company.CompanyName, Company.CompanyCity 
FROM Foods 
CROSS JOIN Company; 

Result

ItemName

ItemUnit

CompanyName

CompanyCity

Mixing

Pcs

Mixing

Florida

Bananas

Pcs

Mixing

Florida

Munching

Pcs

Mixing

Florida

Mixing

Pcs

Trader Joe

Denver

Bananas

Pcs

Trader Joe

Denver

Munching

Pcs

Trader Joe

Denver

© 2019, Alejandro G. Carlstein Ramos Mejia. All rights reserved.

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

*

Click to Insert Smiley

SmileBig SmileGrinLaughFrownBig FrownCryNeutralWinkKissRazzChicCoolAngryReally AngryConfusedQuestionThinkingPainShockYesNoLOLSillyBeautyLashesCuteShyBlushKissedIn LoveDroolGiggleSnickerHeh!SmirkWiltWeepIDKStruggleSide FrownDazedHypnotizedSweatEek!Roll EyesSarcasmDisdainSmugMoney MouthFoot in MouthShut MouthQuietShameBeat UpMeanEvil GrinGrit TeethShoutPissed OffReally PissedMad RazzDrunken RazzSickYawnSleepyDanceClapJumpHandshakeHigh FiveHug LeftHug RightKiss BlowKissingByeGo AwayCall MeOn the PhoneSecretMeetingWavingStopTime OutTalk to the HandLoserLyingDOH!Fingers CrossedWaitingSuspenseTremblePrayWorshipStarvingEatVictoryCurseAlienAngelClownCowboyCyclopsDevilDoctorFemale FighterMale FighterMohawkMusicNerdPartyPirateSkywalkerSnowmanSoldierVampireZombie KillerGhostSkeletonBunnyCatCat 2ChickChickenChicken 2CowCow 2DogDog 2DuckGoatHippoKoalaLionMonkeyMonkey 2MousePandaPigPig 2SheepSheep 2ReindeerSnailTigerTurtleBeerDrinkLiquorCoffeeCakePizzaWatermelonBowlPlateCanFemaleMaleHeartBroken HeartRoseDead RosePeaceYin YangUS FlagMoonStarSunCloudyRainThunderUmbrellaRainbowMusic NoteAirplaneCarIslandAnnouncebrbMailCellPhoneCameraFilmTVClockLampSearchCoinsComputerConsolePresentSoccerCloverPumpkinBombHammerKnifeHandcuffsPillPoopCigarette