SELECT query only of jobids with tagids from all catids

Please support our MS SQL advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2006
Posts: 25
Reputation: forumposters is an unknown quantity at this point 
Solved Threads: 1
forumposters forumposters is offline Offline
Light Poster

SELECT query only of jobids with tagids from all catids

 
0
  #1
Apr 5th, 2007
I have the following select query:

  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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for MS SQL
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC