| | |
SELECT query only of jobids with tagids from all catids
Please support our MS SQL advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: May 2006
Posts: 25
Reputation:
Solved Threads: 1
I have the following select query:
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.
MS SQL Syntax (Toggle Plain Text)
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.
![]() |
Similar Threads
- sql query problem with MS Access and C# (C#)
- database connection(select ,insert query) within javascript function (JSP)
- Select Query Problem in access (MS Access and FileMaker Pro)
- Problems in QUERY (Visual Basic 4 / 5 / 6)
- member group query (MySQL)
- hav a problem with this query (MySQL)
Other Threads in the MS SQL Forum
- Previous Thread: Must declare the scalar variables in storedprocedure in sql 2005
- Next Thread: Trigger help
| Thread Tools | Search this Thread |





