944,117 Members | Top Members by Rank

Ad:
  • MS SQL Discussion Thread
  • Unsolved
  • Views: 1382
  • MS SQL RSS
Apr 5th, 2007
0

SELECT query only of jobids with tagids from all catids

Expand Post »
I have the following select query:

MS SQL Syntax (Toggle Plain Text)
  1. SELECT DISTINCT Job.JobID, Job.DateAdded
  2. FROM Job, ImageTag, Image, Tag, TagCat
  3. WHERE TagCat.TagCatID = Tag.TagCatID AND Tag.TagID = ImageTag.TagID AND ImageTag.JobID = Image.ImageID AND Image.JobID = Job.JobID
  4. AND ImageTag.TagID IN (#TagIDList#)
  5. 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.
Similar Threads
Reputation Points: 10
Solved Threads: 1
Light Poster
forumposters is offline Offline
25 posts
since May 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MS SQL Forum Timeline: Must declare the scalar variables in storedprocedure in sql 2005
Next Thread in MS SQL Forum Timeline: Trigger help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC