Question

Here is my table structure tags table

ID------ TAG_NAME
1         PHP
2         MYSQL

article table

ID----- ART_TITLE -- CATEGORY ---    TAGS    --- CREATED_ON
1       some title1     22         ["1","2"]       13258465
2       some title2     23         ["4","5"]       13258465
3       some title3     21         ["5","7"]       13258465

The tags values are json array. I'm stucked with display articles with tag ID. Can anyone tell me how can I do it or which method do I need to use.

Was it helpful?

Solution

You should have an article_tags (with two columns, tag_id and article_id) table that associates tags to articles in a normalized manner. Having the tags as a JSON array isn't indexable, searchable, etc.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top