I basically would like to merge details from the details table in the row of the master. So let's say I have a master table called tbMaster and a detail table called tbDetail with the following structures:
tbMaster
---------
ID Name
1 John
2 Sam
3 Bob
....
tbDetail
----------------------------------
ID IDmaster detailtype detailvalue
1 1 age 25
2 1 address Longview Drive 48
3 1 wifename Mary
4 2 age 31
5 2 address MI, Courtesy Road 21
6 2 wifename Rhonda
....
I did not build the DB so it's not my design... But now I need to show a dataset where for each master record, I will have extra fields obtained from the detail table like bellow:
SQL result:
ID name age wifename address
--------------------------------------------
1 John 25 Mary Longview Drive 48
2 Sam 31 Rhonda MI, Courtesy Road 21
How can I achieve this? I actually have more than one detail table for the same master with various data inside, so I will need multiple details from multiple detail tables. I guess if I figure out how to do it for one detail table, I can solve the rest of the query.
So far I have no idea where to start... Is this even possible with simple SQL?