can someone take a look at this query for me? thanks.

T

tbrown7777

I am putting emails into an access database. I have a query that queries on
several different characteristics of the email. The problem that i have is
that i get a query item for each attachment or category. The Distinct
command doesn't work and I can't seem to figure out the joins...


SELECT DISTINCT [tblEmail].[Email ID Number], [tblEmail].[Subject],
[tblEmail].[Body], [tblEmail].[FromName], [tblEmail].[ToName],
[tblEmail].[CCName], [tblEmail].[SendDate],
[tblEmailAttachments].[AttachmentName],
[tblEmailAttachments].[AttachmentHyperlink], [tblEmailCategories].[Category],
[tblEmailCategories].[SubCategory]
FROM (tblEmail left JOIN tblEmailAttachments ON [tblEmail].[Email ID
Number]=[tblEmailAttachments].[Email ID Number]) left JOIN tblEmailCategories
ON [tblEmail].[Email ID Number]=[tblEmailCategories].[Email ID Number]
WHERE (((tblEmail.SendDate) BETWEEN #3/24/2001# AND #3/22/2009#) AND
((Tblemail.body) LIKE '* *') AND ((tblEmailCategories.subCategory)= "New
Admin Building"));
 
J

John W. Vinson

I am putting emails into an access database. I have a query that queries on
several different characteristics of the email. The problem that i have is
that i get a query item for each attachment or category. The Distinct
command doesn't work and I can't seem to figure out the joins...


SELECT DISTINCT [tblEmail].[Email ID Number], [tblEmail].[Subject],
[tblEmail].[Body], [tblEmail].[FromName], [tblEmail].[ToName],
[tblEmail].[CCName], [tblEmail].[SendDate],
[tblEmailAttachments].[AttachmentName],
[tblEmailAttachments].[AttachmentHyperlink], [tblEmailCategories].[Category],
[tblEmailCategories].[SubCategory]
FROM (tblEmail left JOIN tblEmailAttachments ON [tblEmail].[Email ID
Number]=[tblEmailAttachments].[Email ID Number]) left JOIN tblEmailCategories
ON [tblEmail].[Email ID Number]=[tblEmailCategories].[Email ID Number]
WHERE (((tblEmail.SendDate) BETWEEN #3/24/2001# AND #3/22/2009#) AND
((Tblemail.body) LIKE '* *') AND ((tblEmailCategories.subCategory)= "New
Admin Building"));

What do you *want* to see? The DISTINCT predicate will give the distinct
records on all of the fields in the SELECT clause. If you don't want to see a
different record for each attachment or each attachment category you will need
to leave them out of the SELECT.
 
Top