高分求一个语句!

cmt123 2003-06-26 10:50:21
table1 表
Column
1
2
3
4
5
6
7
8
.
.
.

table2 表
J_Receipt J_Goods J_Name
s0000s 0101001 ss
s0000q 0101002

求一个SQL语句,生成一个表table3,如下
Column J_Receipt J_Goods J_Name
1 s00000s 01 ss
2 s00000q 02 bb
3
4
5
6
7
8
.
.
.

table1与table2没有关联!



...全文
69 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
愉快的登山者 2003-06-26
  • 打赏
  • 举报
回复
select *, indentity(int,1,1) id into #t from table2
go
select A.Column, B.J_Receipt, B.J_Goods, B.J_Name from table1 A
left jion #t B on A.Column = B.id
Robin 2003-06-26
  • 打赏
  • 举报
回复
呵呵!
题意不清!
joygxd 2003-06-26
  • 打赏
  • 举报
回复
select identity(int,1,1) column,* into #temp from table2

select * from #temp

drop table #temp
pengdali 2003-06-26
  • 打赏
  • 举报
回复
select identity(int,1,1) column,* into #temp from table2
select * from table1 a left join #temp b on a.column=b.column
drop table #temp
pengdali 2003-06-26
  • 打赏
  • 举报
回复
select identity(int,1,1) column,* into #temp from table2
select * from table1 a left join #temp b on a.column=b.column
drop table #temp
longji 2003-06-26
  • 打赏
  • 举报
回复
select identity(int,1,1) as Column,J_Receipt,right(J_Goods,2) as J_Goods,J_Name
into #lfy from table2
select * from #lfy
pengdali 2003-06-26
  • 打赏
  • 举报
回复
select identity(int,1,1) column,* into #temp from table2
select * from table1 a left join #temp b on a.column=b.column
drop table #temp
happydreamer 2003-06-26
  • 打赏
  • 举报
回复
alter table2 add id int identity(1,1)

select Column, J_Receipt , right(J_Goods ,2), J_Name
from table2

alter table2 drop column id
cjt000000 2003-06-26
  • 打赏
  • 举报
回复
up
longji 2003-06-26
  • 打赏
  • 举报
回复
select identity(int,1,1) as Column,J_Receipt,right(J_Goods,2) as J_Goods,J_Name
from table2
是不是需要这种效果!
CrazyFor 2003-06-26
  • 打赏
  • 举报
回复
table1 表
Column
1


table2 表
J_Receipt J_Goods J_Name
select identity(int,1,1) column,* into #temp from table2
select * from table1 a left join #temp b on a.column=b.column
jeck_zhou 2003-06-26
  • 打赏
  • 举报
回复
up

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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