合并3个表

foxmail 2003-11-24 09:14:05
SQl 2000数据库有表1,2,3
主键都为"代码",其他字段名都不同
要根据ID合并到一个数据库该怎么做
谢谢!
...全文
153 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
foxmail 2003-11-28
  • 打赏
  • 举报
回复
我已经自己弄好了
是用select into .....on ... inner join ...的
谢谢大家
lengfeng8866 2003-11-25
  • 打赏
  • 举报
回复
select * from 表1 a
left join 表2 b on a.代码=b.代码
left join 表3 c on a.代码=c.代码 就已经OK了,至于用union all 就不必了。。。。。
txlicenhe 2003-11-25
  • 打赏
  • 举报
回复
也不知道楼主到底想要怎样,估计已经搞定了。
txlicenhe 2003-11-25
  • 打赏
  • 举报
回复
select * from 表1 a
left join 表2 b on a.代码=b.代码
left join 表3 c on a.代码=c.代码
zjcxc 2003-11-25
  • 打赏
  • 举报
回复
select * from 表1 a
join 表2 b on a.代码=b.代码
join 表3 c on a.代码=c.代码
hdslah 2003-11-25
  • 打赏
  • 举报
回复
select * from 表1 a inner join 表2 b on a.id=b.id inner join 表3 c on a.id=c.id
pengdali 2003-11-24
  • 打赏
  • 举报
回复
第一个纵向,第二个是横向。
pengdali 2003-11-24
  • 打赏
  • 举报
回复
select * from 表1,表2,表3 where 表1.代码=表2.代码 and 表1.代码=表3.代码
pengdali 2003-11-24
  • 打赏
  • 举报
回复

select 代码,其他列1 from 表1
union all
select 代码,其他列2 from 表2
union all
select 代码,其他列3 from 表3

27,579

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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