-
Query using joins (many m:n relations)
I have to do the following query sql (sqlite).
Let's start with the description of the tables.
user 1:n interest
interest m:n category
interest m:n location
event m:n category
event m:n location
Each m:n relationship is made possible by an additional table in the structure of interests_categories, events_categories, etc.
I've got users and those users have interests (Categories -> e.g. Sport, Music and locations he likes). Events get tagged with locations and categories.
Now I'd like to list all the users that might fit to a specific events. For example, if there's an event that takes place in NYC and has something todo in sports, I'd like to get a list of users that might be interested in this event based on the location and categories.
I'd like to do it in a single database access instead of multiple. How would that look like in sql? I'll probably have to join the Category/Location tables first, join the interests based on all the tables of the previously join and then select all the users based on the interests. Unfortunately I have very limited knowledge of joins in sql. Or is there a better way to solve this?
Thank you in advance!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|