Join With Comma Separated Values And Search

Hello friends,

How to give relation to comma separated value and search on it.?

I have there tables







Event has many tags

That tags are stroed in Event_Tag Table with comma separted values.

Problem is how to search for tag in Event Model?

Event_Tag Table

event_id 	tag_id

1 	5,3,4,2

2 	5,4,1

3 	3

18 	5,4,3,1

Tag Table

tag_id 	tag_name

1 	Meeting 

2 	Conference

3 	Diwali 	

4 	Client 	

5 	Annual 	

Thanks in Advance.


I think it’s almost impossible, if possible at all. You must redesign your database, it does not complies with 1st normal form (read more here).

Records in event_tag table must look like:

event_id   tag_id

1          5

1          3

2          5

2          4

2          1

3          3

event_id, tag_id must be in primary key, must be indexed and must have foreign keys to the ids in according tables.



Thanks for the reply. I have done it using custom functionality.