By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,276 Members | 1,979 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,276 IT Pros & Developers. It's quick & easy.

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

P: 3
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.
1 Week Ago #1
Share this Question
Share on Google+
1 Reply

Expert Mod 10K+
P: 12,392
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.
1 Week Ago #2

Post your reply

Sign in to post your reply or Sign up for a free account.