|
Probably the best way is to write the query manually using a union:
select D.ID, D.fname, D.lname, T.Date/Time, T.Location, T.info1 as Info, 1 type from Demog D left join Trans_A T on T.ID = D.ID
union all select D.ID, D.fname, D.lname, T.Date/Time, T.Location, T.info2, 2
from Demog D left join Trans_A T on T.ID = D.ID
union all select D.ID, D.fname, D.lname, T.Date/Time, T.Location, T.info3, 3
from Demog D left join Trans_B T on T.ID = D.ID
union all
select D.ID, D.fname, D.lname, T.Date/Time, T.Location, T.info4, 4
from Demog D left join Trans_B T on T.ID = D.ID
union all
select D.ID, D.fname, D.lname, T.Date/Time, T.Location, T.info5, 5
from Demog D left join Trans_C T on T.ID = D.ID
union all
select D.ID, D.fname, D.lname, T.Date/Time, T.Location, T.info6, 6
from Demog D left join Trans_C T on T.ID = D.ID
order by D.ID [...]
I used left joins so the person will be included in the report even if they have no activity in log A, B or C. I added the type so you can distinguish which log the record comes from, if required. I used union all to ensure duplicate records are included (union by itself removes duplicates).
|