【急】两张表合并成一张一表的问题

linjch520 2011-04-01 07:04:52
假如表一(table1)是:
tid name
1 ss
2 ff
6 ee

表二是(table2):
tid tnumber
1 5
2 5
3 5
4 5
5 5
6 5
7 5

要求合成的表(table3)为
tid tnumber name
1 5 ss
2 5 ff
3 5 --
4 5 --
5 5 --
6 5 ee
7 5 --

哪位高手能够帮小弟我解决这一难题啊?感激不尽!在线等待中...
...全文
77 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
lin520 2011-04-03
  • 打赏
  • 举报
回复
自己写了一个:
select `t`.`tid` AS `tid`,`t`.`mnumber` AS `mnumber`,`t`.`snumber` AS `snumber`,`t`.`tleader` AS `tleader`,`t`.`tname` AS `tname`,`t`.`title` AS `title`,group_concat(concat(concat(`s`.`name`,' ')) separator ', ') AS `members`,`t`.`torder` AS `torder` from (`team` `t` left join `students` `s` on((`t`.`tid` = `s`.`tid`))) group by `t`.`tid`
ACMAIN_CHM 2011-04-01
  • 打赏
  • 举报
回复
select tid,tnumber,name
from table2 left join table1 using(tid)
ACMAIN_CHM 2011-04-01
  • 打赏
  • 举报
回复
linjch520 2011-04-01
  • 打赏
  • 举报
回复
已经解决!
linjch520 2011-04-01
  • 打赏
  • 举报
回复
急啊,求解决!

56,687

社区成员

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

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