wvandenberg
Technical User
I have tblSamples containing data about samples collected from specific sites. tblSamples looks like:
[tt]
pkSampleID fkSiteID SampleName SampleDate Round
1787 598 WE73 15/03/2007 1
1786 597 WE71 15/03/2007 1
745 411 WE66 31/07/2007 4
1783 411 WE66 17/03/2007 1
1784 411 WE66 24/04/2007 2
1785 411 E66 27/06/2007 3
1884 411 WE66 07/09/2007 5
1780 596 WE65 12/03/2007 1
1781 596 WE65 30/05/2007 2
1782 596 WE65 28/06/2007 3
1777 595 WE64 12/03/2007 1
1778 595 WE64 24/04/2007 2
1779 595 WE64 28/06/2007 3
1776 594 WE63 15/03/2007 1
1775 593 WE61 15/03/2007 1
[/tt]
I am trying to create a query that will select common samples. A common sample is one that has [Round]=1 AND [Round]=2,3 OR 4. My query SQL is:
It looks like it is selecting the correct records but I was wonding if someone could verify for me. Also, if there is a better way, please don't hesitate.
Wendy
[tt]
pkSampleID fkSiteID SampleName SampleDate Round
1787 598 WE73 15/03/2007 1
1786 597 WE71 15/03/2007 1
745 411 WE66 31/07/2007 4
1783 411 WE66 17/03/2007 1
1784 411 WE66 24/04/2007 2
1785 411 E66 27/06/2007 3
1884 411 WE66 07/09/2007 5
1780 596 WE65 12/03/2007 1
1781 596 WE65 30/05/2007 2
1782 596 WE65 28/06/2007 3
1777 595 WE64 12/03/2007 1
1778 595 WE64 24/04/2007 2
1779 595 WE64 28/06/2007 3
1776 594 WE63 15/03/2007 1
1775 593 WE61 15/03/2007 1
[/tt]
I am trying to create a query that will select common samples. A common sample is one that has [Round]=1 AND [Round]=2,3 OR 4. My query SQL is:
Code:
SELECT DISTINCT tblSamples.SampleName
FROM tblSamples INNER JOIN tblSamples AS tblSamples_1 ON tblSamples.SampleName = tblSamples_1.SampleName
WHERE (((tblSamples.Round)=1) AND ((tblSamples_1.Round) In (2,3,4)))
ORDER BY tblSamples.SampleName;
Wendy