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 dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redundant Logic?

Status
Not open for further replies.

forumposters

Programmer
Aug 31, 2006
61
US
The following query seems to work, but I'm not sure it's the best way to do this. Is there a better way to write this SQL statement? Is there another query that does the same thing, but is shorter and is better form?

SELECT j.jobid
FROM Job j
JOIN Image i
ON j.jobid = i.jobid
JOIN ImageTag it
ON it.ImageID = i.ImageID
JOIN Tag t
ON t.tagid = it.tagid
JOIN TagCat tc
ON tc.tagcatid = t.tagcatid
AND it.tagid IN (<cfqueryparam value="#arguments.TagIDList#" cfsqltype="cf_sql_integer" list="yes"/>)
WHERE i.DisplayImage = 'True'
GROUP
BY j.jobid
HAVING COUNT(distinct tc.TagCatID) >= (SELECT Count(DISTINCT t.tagcatid)
FROM tagcat tc, tag t
WHERE tc.TagCatID = t.TagCatID
AND t.tagid IN
(<cfqueryparam value="#arguments.TagIDList#" cfsqltype="cf_sql_integer" list="yes"/>)
)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top