I am creating a website like Stack Overflow.
When we post new questions on "stack-overflow", we give some tags which are related to our question.
I have one field named as q_related_tag_ids
(question related tag ids) in table question
.
I use this field to store all tag_ids
separated by commas (,
) which are related to posted question.
Table Question >>
q_id | q_title | q_ralated_tag_ids
1 | title1 | 4,5,8
2 | title2 | 6,8,1
3 | title3 | 2,81,13
4 | title4 | 8
3 | title3 | 2,87
4 | title4 | 83
Table Answer >>
t_id | t_name | t_description
1 | java | java is ...
2 | php | php is ...
3 | ajax | ajax is ...
4 | c++ | c++ is ...
5 | perl | perl is ...
8 | java8 | java8 is...
...
Now the problem is >>
I want to get/select all question details which are related to tag-id = 8
, or related to the java8
tag
For that, I have created a query >>
select * from question where (
q_related_tag_ids like '8'
or q_related_tag_ids like '%,8,%'
or q_related_tag_ids like '%,8')
Does anyone have any better approach?