The parameters are thus:
- I have a table called Tasks with columns ID (primary key) and label (text).
- I have another table called Locations with a foreign key referencing Tasks' ID and a name for a location (text).
- In my code I have a set of locations.
- UPDATED: I need a query to return all tasks that have associated locations found within my set. Each task that has an associated location not found in my set must be t开发者_如何学JAVAhrown out.
What's the best way to go about this?
For the modified requirement:
select * from tasks t
where exists (select null from locations l
where t.id = l.task_id and l.name in ('London', 'Geneva'...)) and
not exists (select null from locations l
where t.id = l.task_id and l.name not in ('London', 'Geneva'...))
精彩评论