我试图联接两个表,以便将表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,但它们不是基于文本数据的。