1 / 35

Types of Joins

This article provides a detailed explanation of the different types of joins, including inner join, left join, right join, and full join. Learn how to connect two or more tables using SQL join commands and discover the various scenarios where each type of join is applicable.

rdonnelly
Download Presentation

Types of Joins

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Types of Joins • Farrokh Alemi, Ph.D.

  2. Link Data across 2 or More Tables

  3. Inner Join SELECTcolumn_name(s)FROM table1 INNERJOIN table2  ON table1.column_name = table2.column_name;

  4. Inner Join Unique or Addressed SELECTcolumn_name(s)FROM table1 INNERJOIN table2  ON table1.column_name = table2.column_name;

  5. Inner Join SELECTcolumn_name(s)FROM table1 INNERJOIN table2  ON table1.column_name = table2.column_name;

  6. Inner Join • Inner Join SELECTcolumn_name(s)FROM table1 INNERJOIN table2  ON table1.column_name = table2.column_name;

  7. Inner Join SELECTcolumn_name(s)FROM table1 INNERJOIN table2  ON table1.column_name = table2.column_name;

  8. Inner Join

  9. Inner Join

  10. Inner Join SELECTc.*, d.*FROM [Dx Codes] d inner join [Encounter] e ONd.[Code ID] = e.[Diagnosis ID]

  11. Alias Alias Alias SELECTd.*, e.*FROM [Dx Codes] d inner join[Encounter] eONd.[Code ID] = e.[Diagnosis ID]

  12. Inner Join SELECTd.*, e.*FROM [Dx Codes] d inner join [Encounter] e ONd.[Code ID] = e.[Diagnosis ID]

  13. Inner Join No Matching 6 SELECTd.*, e.*FROM [Dx Codes] d inner join [Encounter] e ONd.[Code ID] = e.[Diagnosis ID] 6

  14. Inner Join SELECTd.*, e.*FROM [Dx Codes] d inner join [Encounter] e ONd.[Code ID] = e.[Diagnosis ID] Check Total Rows in Combined & Component Tables No Match Entire Record Gone POOF!

  15. Cross Join • Left/Right Join All of Left Table Records Listed

  16. Cross Join • Left/Right Join All of Right Table Records Listed

  17. Cross Join • Left/Right Join SELECTd.*, e.*FROM [Dx Codes] d right join [Encounter] e ONd.[Code ID] = e.[Diagnosis ID]

  18. Cross Join • Left/Right Join SELECTd.*, e.*FROM [Dx Codes] d right join [Encounter] e ONd.[Code ID] = e.[Diagnosis ID]

  19. SELECTd.*, e.*FROM [Dx Codes] d right join [Encounter] e ONd.[Code ID] = e.[Diagnosis ID] • Cross Join • Left/Right Join

  20. Cross Join • Left/Right Join SELECTd.*, e.*FROM [Dx Codes] d left join [Encounter] e ONd.[Code ID] = e.[Diagnosis ID]

  21. Cross Join • Left/Right Join SELECTd.*, e.*FROM [Dx Codes] d left join [Encounter] e ONd.[Code ID] = e.[Diagnosis ID]

  22. SELECTd.*, e.*FROM [Dx Codes] d left join [Encounter] e ONd.[Code ID] = e.[Diagnosis ID] • Cross Join • Left/Right Join

  23. Cross Join • Full Join All Records Listed All Records Listed

  24. Cross Join • Full Join SELECTd.*, e.*FROM [Dx Codes] d full join [Encounter] e ONd.[Code ID] = e.[Diagnosis ID]

  25. Cross Join • Full Join SELECTd.*, e.*FROM [Dx Codes] d full join [Encounter] e ONd.[Code ID] = e.[Diagnosis ID]

  26. Cross Join • Full Join SELECTd.*, e.*FROM [Dx Codes] d full join [Encounter] e ONd.[Code ID] = e.[Diagnosis ID]

  27. SELECTd.*, e.*FROM [Dx Codes] d full join [Encounter] e ONd.[Code ID] = e.[Diagnosis ID] • Cross Join • Full Join

  28. Cross Join • Cross Join All Possible Combinations Without any Restrictions

  29. Cross Join • Cross Join SELECTd.*, e.*FROM [Dx Codes] d cross join [Encounter] e ON d.[Code ID] = e.[Diagnosis ID]

  30. SELECTd.*, e.*FROM [Dx Codes] d cross join [Encounter] e • Cross Join • Cross Join

  31. SELECTd.*, e.*FROM [Dx Codes] d cross join [Encounter] e • Cross Join • Cross Join

  32. SELECTd.*, e.*FROM [Dx Codes] d cross join [Encounter] e • Cross Join • Cross Join

  33. Cross Join • Cross Join All Possible Combinations Lots of Data

  34. Join command Connects two or More tables

More Related