Retrieve all tags for all results in MYSQL Query -
i working on video tagging system. know unique id each video want in search result previous query have run, want show of tags each video in search result in listing it's multiple categories , contributors displayed without having click through main page.
the code below returns 5 rows 2 videos in search results. can loop around result, means can't use limit functions , have build php me.
select * tags join siteupdates on tags.item_id = siteupdates.clip_id join updatetype on siteupdates.updatetype = updatetype.id_type join tagnames on tags.tag = tagnames.tagid tags.item_id in (248,257) order siteupdates.clip_date desc
result (this example of first 5 results, , have cut out of columns aren't relevant)
uid / item_id / tag / updatetype / tagname / tagtype 1560 / 248 / 14 / 1 / tag 14 / category 1561 / 248 / 3 / 1 / tag 3 / contributor 1562 / 248 / 7 / 1 / tag 7 / category 543 / 257 / 43 / 1 / tag 43 / category 544 / 257 / 3 / 1 / tag 3 / contributor
ideally need 2 row result, containing of tag data.
alternatively, asking isn't possible just mysql , original plan loop around in php option? new query tag info each result not sound idea me possible have 50 results per page, 52 queries in total (including 1 earlier in script)!
any appreciated.
so if right want of tags, not 1 tag per result record in one? in case group_concat() might help.
Comments
Post a Comment