SQL 语句问题

天边一坨浮云 技术中心总经理  2011-02-24 05:29:26
表A
列1 列2 列3
a1 b1 c1
a2 b2 c2
表B
列1 列2 列3
d1 e1 f1
d2 e2 f2
A,B表无任何关系,如何用select实现以下结果
列1 列2 列3 列4 列5 列6
a1 b1 c1 d1 e1 f1
a2 b2 c2 d2 e2 f2

也就是表A和表B连接起来,1条A的记录连接1条B的记录就行,无视顺序
...全文
29 点赞 收藏 5
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
gw6328 2011-02-24


select * from a corss join b
-- 在这里面自选 自助餐

回复
快溜 2011-02-24
 select * from 
(select row_number() over(order by 列1) as no,* from tb1) a
left join
(select row_number() over(order by 列1) as no,* from tb2)b
on a.no=b.no
回复

with cte as
(
select rn = row_number() over (order by getdate()),*
from a
),cta as
(
select rn = row_number() over (order by getdate()),*
from b
)

select *
from cte inner join cta on cte.rn = cta.rn

回复

with cte as
(
select rn = row_number() over (order by getdate()),*
from a
),cta as
(
select rn = row_number() over (order by getdate()),*
from b
)

select *
from cte left join cta on cte.rn = cta.rn
回复
发动态
发帖子
疑难问题
创建于2007-09-28

2.1w+

社区成员

MS-SQL Server 疑难问题
申请成为版主
社区公告
暂无公告