我现在几乎尽我所能来解决他的以下问题。到目前为止没有成功。但必须有一个解决方案,因为我不认为这个案子太特别了。我想我只是一个该死的初学者;-)我需要在 MySQL 中加入 union merge 或其他什么;-) 来解决以下问题......
案例:三个表“posts”、“tagmap”和“tags”
tagmap表存储所有 nm 关系,posts 的 id 和 tags 的id
tags表存储tag_name和tag id posts
表存储post_title和post_id
posts post_id post_title
1 Charlie Chaplin Painting
tagmap id post_id tag_id
100 1 12
101 1 13
102 1 14
tags tag_id tag_name
12 Acryl
13 Chalk
14 Poster
我想要实现的是获得一个结果,即所有相关标签都合并在一列中。通过逗号分隔的列表或空格:
post_id => 1, post_title => Charlie Chaplin... tag_name => Acryl, Chalk, Poster
但到目前为止,我唯一能得到的是这样的多重结果:
post_id => 1,post_title => Charlie Chaplin... tag_name => Acryl
post_id => 1,post_title => Charlie Chaplin... tag_name => Chalk
post_id => 1, post_title => 查理卓别林... tag_name => 海报
有谁知道如何实现这一点...任何帮助将不胜感激,并提前感谢所有可以帮助我的人;-)