+4  A: 

Sounds like a join may help you

select s.*,
  b.tag,
  b.slug
from story_table s
  left join bt_tags b on b.tid in s.tags

Join Syntax at dev.mysql.com

ctshryock
this seams to be great bro! ;-)
aSeptik
I dont know why i cant set this to work , actually , tag ids stored in stories table seprated by space not comma
Mac Taylor
and how to show array of tag names ? just $row['tag'] ? plz help to complete this script
Mac Taylor
The example query is in short hand; you'll need to swap out somethings. In place of `s.tags` you could probably use your `$tags_id` variable
ctshryock
would you mind updating your answer , i think with example , i can understand it better .
Mac Taylor
"tag ids stored in stories table seprated by space not comma" Makes this very difficult. If you have a to-many relationship which you seem to have you should probably be using a cross reference table of sorts instead. If you can, convert your spaces to commas in this field. Using `$tags_id` is also not an option as I suggested; it's made after you run the first query, which is counter to what you're trying to do.
ctshryock
I can't tell without running it but you should try @mark-baker's solution
ctshryock
the only problem to your code is that it fetches only first tag name and not the rest
Mac Taylor
hey man how can i use two group_concat togather ?!
Mac Taylor
+4  A: 
SELECT stories.storyid,
       stories.storyname, 
       group_concat( tags.tagname ) 
  FROM stories, tags
 WHERE CONCAT( ' ', stories.tags, ' ' ) LIKE CONCAT( '%', tags.tagid, '%' ) 
 GROUP BY stories.storyid, stories.storyname
Mark Baker
nice one but i was not successful to make it work , how can i show the array of tag names after query that
Mac Taylor
Change `group_concat( tags.tagname ) ` to `group_concat( tags.tagname ) as mytags`, replacing `mytags` with whatever you want, and you should be able to reference it like `$row['mytags']`
ctshryock
wow thanks man , you are my hero
Mac Taylor