I have two tables in the MySQL database, Locations and Tags, and a third LocationsTagsAssoc table that links the two tables and treats them as a many-to-many relationship.
The structure of the table is as follows:
Locations
---------
ID int (Primary Key)
Name varchar(128)
LocationsTagsAssoc
------------------
ID int (Primary Key)
LocationID int (Foreign Key)
TagID int (Foreign Key)
Tags
----
ID int (Primary Key)
Name varchar(128)
Thus, each place can be tagged with multiple tags, and each of them can be tagged at multiple locations.
What I want to do is select only the locations that are marked with all the tag names indicated . For instance:
I want all locations marked with “trees” and “swings”. You must select the Park location, but the Forest location should not be.
. !