So, I’m new in PHP and Database and I have a problem here:
I have a table called news and one of its column is tags. This column contains 1 or more tags separated by whitespaces, like economics politics sports. And I have a page which will receive one or more tags as a single parameter and I have to return all rows that contains at least one of this tags.
I could explode the tags and do as many database access as necessary but I’m sure this is not the way to do it =p
LIKE and IN won’t work either because the paramater may contain more than 1 tag in any order.
Any help?
That isn’t how to structure that.
Have a table called news, one called tags, and one called tagsToNews.
In tagsToNews just record the news items ID and the tag ID, then do a join to get what you want. This also means a tag can be renamed without breaking everything!