表1:table1id name
1 刘
2 王
3 赵表2:table2
tableId jointIds
1 1,2
2 2,1
3 3,1,2希望结果:
tableId tableName jointIds jointNames
1 刘 1,2 刘,王
2 王 2,1 王,刘
3 赵 3,1,2 赵.刘,王这里只能给100,若分不够,另开窗口曾分。求大神~~
1 刘
2 王
3 赵表2:table2
tableId jointIds
1 1,2
2 2,1
3 3,1,2希望结果:
tableId tableName jointIds jointNames
1 刘 1,2 刘,王
2 王 2,1 王,刘
3 赵 3,1,2 赵.刘,王这里只能给100,若分不够,另开窗口曾分。求大神~~
select b.tableId,a.name as tableName,b.jointIds
group_concat(c.name) as jointNames
from table1 a ,table2 b, table1 c
where find_in_set( c.id,b.jointIds)
and a.id= b.tableId
group by b.tableId