你的表結構有點問題,不應該用中文去搜索tagid的。表結構應該改成這樣 article表 id topictag表 id namearticle與tag關聯表 article_tag id article_id tag_id你需要查詢某篇文章的tag可以這樣select * from tag where id in(select tag_id from article_tag where article_id=文章id)
表的设计有点问题;建议这样做新闻表 【new】 newid 编号 title 名称标签表【tag】 id newid tagname【新闻表对应多个字符隔开的标签】select new.title,tag.tagname from new left join tag on new.newid=tag.newid
article表
id
topictag表
id
namearticle與tag關聯表
article_tag
id
article_id
tag_id你需要查詢某篇文章的tag可以這樣select * from tag where id in(select tag_id from article_tag where article_id=文章id)
newid 编号
title 名称标签表【tag】
id
newid
tagname【新闻表对应多个字符隔开的标签】select new.title,tag.tagname from new left join tag on new.newid=tag.newid