I'm still trying to learn SQL as of this writing, so I'm a bit shakey at the moment.
My situation is like this:
- I have a table called 'Tasks' with an auto-incrementing primary key ID and a text field (and a few others that aren't relevant to this problem, too).
- I have another table called 'Locations' with a foreign key referring to a task by ID and a text field representing the location's name. These map sets of locations to given specific tasks (one-to-many I think it's called).
- I have a data structure in my code containing a list of location values. I want to query for tasks that have at least all of these locations associated with them.
- I will have other tables with similar one-to-many relationships as well that I'll need to use as the basis of task querying. They might also be used to filter each others' queried results. How do I stack several of these kinds of filters within my SQL use (as opposed to ANDing between the result sets in my code, manually)?
It seems like it should be simple, but I suppose I simply lack imagination at the moment. There will be more of these sorts of problems for me down the road, so seeing an example of what solves this will help for those as well.