我对MySQL中动态枢轴表的概念很陌生
这是我的模式
表格文章
article_id,article_name,
表利息
interest_id,interest_name,
表Article_Interest_relation
||article_id _ interest_id _
我想把像这样的东西都拿来
条款->利息1 ->利息2 ->利息3.利息'N‘
|| Ipad | technology | science | engineering |..... | Interest 'N' ||如何创建动态列(取决于兴趣的数量)和获取?
我想用枢轴表来做这个吗?
发布于 2015-04-13 10:52:56
我不确定你是否真的需要一个支点解决方案。
但是,您可以在使用group_concat的同时使用join作为适当的解决方案。
select a.article_id
, group_concat( i.interest_name ) as interests
from articles a
join article_interest_relation air on a.article_id=air.article_id
join interests i on i.interest_id=air.interest_id
group by a.article_idhttps://stackoverflow.com/questions/29603439
复制相似问题