Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select only if a tag is matched in every category.

Status
Not open for further replies.

forumposters

Programmer
Aug 31, 2006
61
US
I have the following select query:
SELECT DISTINCT Job.JobID, Job.DateAdded
FROM Job, ImageTag, Image, Tag, TagCat
WHERE TagCat.TagCatID = Tag.TagCatID AND Tag.TagID = ImageTag.TagID AND ImageTag.JobID = Image.ImageID AND Image.JobID = Job.JobID
AND ImageTag.TagID IN (#TagIDList#)
ORDER BY Job.DateAdded DESC

However, I need to add to the query the following:
I only want to select jobids that have images with tags from every tag category that the list of tags has. For example, if the taglist has 5 tagids (34, 56, 57, 67, 88) and tagids 34,56 have tagcatid 2, 57 has tagcatid 5, and 67 and 88 have tagcatid 8, then the jobids must have imageids with tagids that have a tagcatid from all three of these categories.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top