In Microsoft Access, looking to combine three tables into one using a SQL Query:
ID: 3745917 • Letter: I
Question
In Microsoft Access, looking to combine three tables into one using a SQL Query:
Three Tables-->
Lab1(Lab1ID, FirstName, LastName, FullName, SSN, Biomarkers1)
Lab2(Lab2ID, FirstName, LastName, FullName, SSN, Biomarkers2)
Lab3(Lab3ID, FirstName, LastName, FullName, SSN, Biomarkers3)
I would like to have-->
PatientQuery(Lab1ID, Lab2ID, Lab3ID, FirstName, LastName, FullName, SSN)
I am confused on the syntax, thanks
I have something like this so far, SELECT FirstName, LastName From [Lab1];
Union
SELECT [FirstName], [LastName] From [Lab2];
Union
SELECT [FirstName], [LastName] From [Lab3]
Order by LastName, FirstName
The FirstName, LastName, should link everything together?
Explanation / Answer
in this case we need to use RIGHT joint.
query will be like
SELECT Lab1.Lab1ID, Lab1.FirstName,Lab1.LastName,Lab1.SSN,
FROM Lab1
RIGHT JOIN Lab2 ON Lab1.SSN=Lab2.SSN
RIGHT JOIN Lab2 ON Lab1.SSN=Lab3.SSN
Order by LastName, FirstName
SSN or first/lastname can link everything together
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.