A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Query crosses 3 tables



 
 
Thread Tools Display Modes
  #1  
Old April 29th, 2010, 09:11 AM posted to microsoft.public.access.queries
Jeff
external usenet poster
 
Posts: 1,347
Default Query crosses 3 tables

I have 3 tables. tblPatient contains ID, Name, Age....., tblAdmission
contains ID, PatientID, AdmissionDate....., tblCertificate contains ID,
PatientID, AdmissionDate.....

How to combine the following 2 queries into one that crosses 3 tables?
(Please note that the WHERE clause in the second query has error by itself).
Thank you.

SELECT tblPatient.*, tblCertificate.*
FROM tblPatient INNER JOIN tblCertificate
ON tblPatient.ID = tblCertificate.PatientID
WHERE tblCertificate.ID = Me!txtID

SELECT tblPatient.*, tblAdmission.*
FROM tblPatient INNER JOIN tblAdmission
ON tblPatient.ID = tblAdmission.PatientID
WHERE tblAdmission.AdmissionDate = tblCertificate.Admission
--
Jeff
  #2  
Old April 29th, 2010, 01:31 PM posted to microsoft.public.access.queries
vanderghast
external usenet poster
 
Posts: 593
Default Query crosses 3 tables

You need parenthesis, something like:

SELECT tblPatient.*, tblCertificate.*, tblAdmission.*
FROM ( tblPatient INNER JOIN tblCertificate
ON tblPatient.ID = tblCertificate.PatientID )
INNER JOIN tblAdmission
ON tblPatient.ID = tblAdmission.PatientID
AND tblAdmission.AdmissionDate = tblCertificate.Admission
WHERE tblCertificate.ID = Me!txtID


Alternatively, you can use the graphical designer and simply make the three
"links" .



Vanderghast, Access MVP


"Jeff" wrote in message
...
I have 3 tables. tblPatient contains ID, Name, Age....., tblAdmission
contains ID, PatientID, AdmissionDate....., tblCertificate contains ID,
PatientID, AdmissionDate.....

How to combine the following 2 queries into one that crosses 3 tables?
(Please note that the WHERE clause in the second query has error by
itself).
Thank you.

SELECT tblPatient.*, tblCertificate.*
FROM tblPatient INNER JOIN tblCertificate
ON tblPatient.ID = tblCertificate.PatientID
WHERE tblCertificate.ID = Me!txtID

SELECT tblPatient.*, tblAdmission.*
FROM tblPatient INNER JOIN tblAdmission
ON tblPatient.ID = tblAdmission.PatientID
WHERE tblAdmission.AdmissionDate = tblCertificate.Admission
--
Jeff


  #3  
Old April 29th, 2010, 11:52 PM posted to microsoft.public.access.queries
Jeff
external usenet poster
 
Posts: 1,347
Default Query crosses 3 tables

Thank you very much.
--
Jeff


"vanderghast" 來函:

You need parenthesis, something like:

SELECT tblPatient.*, tblCertificate.*, tblAdmission.*
FROM ( tblPatient INNER JOIN tblCertificate
ON tblPatient.ID = tblCertificate.PatientID )
INNER JOIN tblAdmission
ON tblPatient.ID = tblAdmission.PatientID
AND tblAdmission.AdmissionDate = tblCertificate.Admission
WHERE tblCertificate.ID = Me!txtID


Alternatively, you can use the graphical designer and simply make the three
"links" .



Vanderghast, Access MVP


"Jeff" wrote in message
...
I have 3 tables. tblPatient contains ID, Name, Age....., tblAdmission
contains ID, PatientID, AdmissionDate....., tblCertificate contains ID,
PatientID, AdmissionDate.....

How to combine the following 2 queries into one that crosses 3 tables?
(Please note that the WHERE clause in the second query has error by
itself).
Thank you.

SELECT tblPatient.*, tblCertificate.*
FROM tblPatient INNER JOIN tblCertificate
ON tblPatient.ID = tblCertificate.PatientID
WHERE tblCertificate.ID = Me!txtID

SELECT tblPatient.*, tblAdmission.*
FROM tblPatient INNER JOIN tblAdmission
ON tblPatient.ID = tblAdmission.PatientID
WHERE tblAdmission.AdmissionDate = tblCertificate.Admission
--
Jeff


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:02 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.