MySQL将另一个表的varchar行合并为列

时间:2019-03-10 14:42:30

标签: mysql

我试图联接两个表,以便将表2行中存储的数据作为列联接到表1上。

work_tickets:

wt_id  problem
1        TV
2        Lights
3        TV

wt_follow_up

follow_up_id   wt_id   description
1                1      not at home
2                2      changed bulb
3                1      fixed tv

当前:

wt_id    problem   description
1        TV        not at home
1        TV        fixed tv
2        Lights    changed bulb
3

所需:

wt_id    problem   follow_up1      follow_up2
1         TV       not at home     fixed tv
2         Lights   changed bulb
3         TV     

我看过SQL multiple rows as columns (optimizing)MySQL - Rows to Columns,但它们不是基于文本数据的。

0 个答案:

没有答案