G
Guest
I have a table with a person's info and two tables of photos associated with
the person. Here are the relevant tables and fields for the query:
Personal Information (Table):
PersonalID (PK)
First Name
Last Name
CategoryID
SubCategoryID
Photographs (Table):
PersonalID (FK)
PhotoFileName
TagIdentifiers:
PersonalID (FK)
Tag
GangCategories (Table):
CategoryID
GangCategory
GangSubCategories (Table):
SubCategoryID
GangSubCategory
I have created a sample person and a query with this sql statement:
SELECT [Personal Information].[First Name], [Personal Information].[Last
Name], GangCategories.GangCategory, GangSubCategories.GangSubCategory,
Photographs.PhotoFileName, TagIdentifiers.Tag
FROM ((([Personal Information] LEFT JOIN GangCategories ON [Personal
Information].CategoryID=GangCategories.CategoryID)
LEFT JOIN GangSubCategories ON [Personal
Information].SubCategoryID=GangSubCategories.SubCategoryID)
LEFT JOIN Photographs ON [Personal
Information].PersonalID=Photographs.PersonalID)
LEFT JOIN TagIdentifiers ON [Personal
Information].PersonalID=TagIdentifiers.PersonalID
WHERE ((([Personal Information].[PersonalID])= 25));
Which gives these results:
First Name Last Name GangCategory GangSubCategory PhotoFileName Tag
Bob Smith Street Gang OMG Sub 1 thumb1.jpg tag1.jpg
Bob Smith Street Gang OMG Sub 1 thumb1.jpg tag2.jpg
Bob Smith Street Gang OMG Sub 1 thumb1.jpg tag3.jpg
Bob Smith Street Gang OMG Sub 1 thumb2.jpg tag1.jpg
Bob Smith Street Gang OMG Sub 1 thumb2.jpg tag2.jpg
Bob Smith Street Gang OMG Sub 1 thumb2.jpg tag3.jpg
Bob Smith Street Gang OMG Sub 1 thumb3.jpg tag1.jpg
Bob Smith Street Gang OMG Sub 1 thumb3.jpg tag2.jpg
Bob Smith Street Gang OMG Sub 1 thumb3.jpg tag3.jpg
But I would prefer a result like this, where photos or tags aren't duplicated:
First Name Last Name GangCategory GangSubCategory PhotoFileName Tag
Bob Smith Street Gang OMG Sub 1 thumb1.jpg tag1.jpg
Bob Smith Street Gang OMG Sub 1 thumb2.jpg tag2.jpg
Bob Smith Street Gang OMG Sub 1 thumb3.jpg tag3.jpg
What I would like to do is use this for a report that would display the
person's info and each photo and tag below that. The result I have now will
show the person's info then the first photo, all three tags, the second
photo, all three tags, and on. How do I fix this? Any help would be
appreciated.
the person. Here are the relevant tables and fields for the query:
Personal Information (Table):
PersonalID (PK)
First Name
Last Name
CategoryID
SubCategoryID
Photographs (Table):
PersonalID (FK)
PhotoFileName
TagIdentifiers:
PersonalID (FK)
Tag
GangCategories (Table):
CategoryID
GangCategory
GangSubCategories (Table):
SubCategoryID
GangSubCategory
I have created a sample person and a query with this sql statement:
SELECT [Personal Information].[First Name], [Personal Information].[Last
Name], GangCategories.GangCategory, GangSubCategories.GangSubCategory,
Photographs.PhotoFileName, TagIdentifiers.Tag
FROM ((([Personal Information] LEFT JOIN GangCategories ON [Personal
Information].CategoryID=GangCategories.CategoryID)
LEFT JOIN GangSubCategories ON [Personal
Information].SubCategoryID=GangSubCategories.SubCategoryID)
LEFT JOIN Photographs ON [Personal
Information].PersonalID=Photographs.PersonalID)
LEFT JOIN TagIdentifiers ON [Personal
Information].PersonalID=TagIdentifiers.PersonalID
WHERE ((([Personal Information].[PersonalID])= 25));
Which gives these results:
First Name Last Name GangCategory GangSubCategory PhotoFileName Tag
Bob Smith Street Gang OMG Sub 1 thumb1.jpg tag1.jpg
Bob Smith Street Gang OMG Sub 1 thumb1.jpg tag2.jpg
Bob Smith Street Gang OMG Sub 1 thumb1.jpg tag3.jpg
Bob Smith Street Gang OMG Sub 1 thumb2.jpg tag1.jpg
Bob Smith Street Gang OMG Sub 1 thumb2.jpg tag2.jpg
Bob Smith Street Gang OMG Sub 1 thumb2.jpg tag3.jpg
Bob Smith Street Gang OMG Sub 1 thumb3.jpg tag1.jpg
Bob Smith Street Gang OMG Sub 1 thumb3.jpg tag2.jpg
Bob Smith Street Gang OMG Sub 1 thumb3.jpg tag3.jpg
But I would prefer a result like this, where photos or tags aren't duplicated:
First Name Last Name GangCategory GangSubCategory PhotoFileName Tag
Bob Smith Street Gang OMG Sub 1 thumb1.jpg tag1.jpg
Bob Smith Street Gang OMG Sub 1 thumb2.jpg tag2.jpg
Bob Smith Street Gang OMG Sub 1 thumb3.jpg tag3.jpg
What I would like to do is use this for a report that would display the
person's info and each photo and tag below that. The result I have now will
show the person's info then the first photo, all three tags, the second
photo, all three tags, and on. How do I fix this? Any help would be
appreciated.