Join 2 tables, and preserve multiple entries for the 1 ID

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Beccybyte
    New Member
    • Feb 2020
    • 3

    Join 2 tables, and preserve multiple entries for the 1 ID

    I am working with some data for an automotive manufacturer and I want to create a dataset which includes every vehicle sale, and every vehicle service in the last 2 years.

    In my sales table, I have a list of all of the vehicle serial numbers and the purchase date.

    In my Vehicle Service table, I have every Service booked in a period of time, including the vehicle Serial number, the service date, and the cost.

    How can I combine these so that I will preserve all of the service entries (either every service entry has a row, or it's own column)? My preference would be for the adding of the service data, to just create a duplicate Sales entry for it to attach to ie. Add rows where multiple services for the same vehicle serial number exist.

    Not every vehicle in the Sales table will have corresponding services, but every service entry should be able to be linked to a sales entry.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    You're looking for an outer join. A left or right outer join selects all records from one table and all potential matching records from a second table. If the second table has no matching record, then those fields from that table will be null.

    Comment

    Working...