looping query
I can't quite seem to grasp the logic of this. I have a bunch of tags for each of my blog entry, and am trying to filter by tags.
I want to do a query that lists only the blogs that have all the specified tags. I have a table of blog entries, a table of tags, and I have a table of links, it has only the ID and two columns, one is the blogID and one is the tagID
I have a value list which are all the tags the user has requested in the session scope (SESSION.blogTags)
This query gets me all the blog posts which have ANY of the user requested tags
<cfquery name="rsTaggedBlogs" datasource="committedsardine">
SELECT blogID
FROM blogTagLink
<cfif SESSION.blogTags NEQ "">WHERE tagID IN(#SESSION.blogTags#)</cfif>
</cfquery>
<cfset taggedBlogs = ValueList(rsTaggedBlogs.blogID)>
I am then query for my blog entries using the taggedBlogs value list. What I want to do is get only the blog IDs that have ALL the tags as opposed to ANY of the tags.
I'm thinking that some form of cfloop is used here, but just can't seem to get my head around it. Any help would be greatly appreciated.
