mysql - Search database for specific tags -
i have image table column called tags. typical entry this:
id link tags ------------------- 1 [link] funny,not-cool,work i have search page users can enter tags search images. enter amount of tags separated comma
search: funny, fall, fail question is, best way search database these tags? simple like it? know may have been more ideal add each tag in different table , not have them comma separated if need change way tags work will.
it better have multiple tables here. first table called images , id , link. second table called tags each row being 1 specific tag such columns id , tag. third table join table called imagetags columns id, image, , tag. image column in imagetags foreign key images , tag column foreign key tags.
using example search sql like:
select images.link images join imagetags on images.id = imagetags.image join tags on tags.id = imagetags.tag tags.tag in ('funny','fall','fail')
Comments
Post a Comment