In MySQL there is a table with records, also in a separate table are the "record id" — "id tag" that indicate which tags have marked the entry.
You need to select the records according to the user defined tags. While the tags in the query can be several and in this case, it selects all records that contain at least one of the following in the query tags.
A variant in which for each label creates a separate field in the table record is not suitable, because if necessary you want to add a new label without the code changes the sql query.
Could you tell me what sql query to do this sample?