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.preferred_car_type = 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.