求高人帮人,一MYSQL查询。

shuai45 2013-07-10 07:16:36
表1:table1

id 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,若分不够,另开窗口曾分。求大神~~
...全文
121 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
shuai45 2013-07-10
  • 打赏
  • 举报
回复
引用 1 楼 ACMAIN_CHM 的回复:
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
版主就是版主,太给力啦。运行没问题,结果没问题,结贴没问题。
ACMAIN_CHM 2013-07-10
  • 打赏
  • 举报
回复
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

56,940

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧