I have a database where I store posts with ids for tags, categories and types.
For example I have a database table for posts like this:
ID | NAME | TAGS | CATEGORIES | TYPE |
---|---|---|---|---|
1 | News | 12,13,4 | 1,4,22 | 20,21 |
2 | Text | 12,4 | 1,3,5 | 15 |
3 | Docs | 12,13,4 | 4,8,22 | 13,20 |
Now I want to make a mysql query to get all entries with the following ids:
TAGS (12 or 4) & CATEGORIES (1 or 4) & TYPE (20)
The query should return the posts 1 and 3 (News and Docs)
How can I get the right results?