Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Medical Center database
Non primary-foreign key JOINs
Non-equi JOINs
Non-equi self JOINs
Summary
25. Summary

Instruction

Alright! Let's summarize everything we learned in this part.

  • We don't have to join tables on the primary-foreign key relationship. It is possible to use any two columns:
    SELECT
      Buyer.Name,
      Car.Name
    FROM Buyer
    JOIN Car
      ON Owner.PreferredCarType = Car.Type
    
    The query above will show the name of every buyer together with every car that matches their preferred type.
  • We also don't have to use the equality operator when joining tables. We are free to use other comparison operators (<, >, <=, >=, !=, <>) or the BETWEEN operator:
    SELECT
      Auctioneer.Name,
      Item.Name
    FROM Auctioneer
    JOIN Item
      ON Auctioneer.Funds > Item.Price
    
  • We can write a special kind of JOIN to list items within a certain range (for example, within a budget), all pairs of items, or all unique pairs.

Exercise

Click the Next exercise button to continue.