I'm building an event-related application where I have user defined "streams" of events. When a new event is added to the system, I need to find the streams to which the event should be added.

The event takes place at a venue (which belongs to a city), belongs to a category, is organized by an organization and is tagged with certain tags (among other things).

The streams have filters. So I can have a stream that only wants events from a particular city (without caring which venue it is at, who the organizer is, etc). I can have another stream where I only want events by a certain organizer. Or I can have a stream where I only want events from, say, 3 categories in a certain city.

A filter can be set to "any" (represented as 0) or it can be one or more id's of the thing it's filtering. To be flexible, I created a "filters" table with the following columns:

id | stream_id | filter | value

Say I only have 4 filters which are saved as such (0 means any; multiple values for the same filter are saved as separate records - see row 16 and 17):

r937 - seems to work perfectly. Not that I am very surprised given your credentials. lol

Thank you kindly!

luco_vico
—
2012-09-11T07:00:12Z —
#5

I have a follow-up question. The query seems to work, but not in all cases. The situation where it does not work is when the new event is tagged with more than one matching 'tag'. Since the IN array is dynamically generated based on the new event details, if this is the generated query: