现在我有两个表
表a:
order_id tel
a中现有一个订单有两条记录
aaa-1000 1580000000
aaa-1000 1580000001
表b:
order_id pp_id
b中对应订单号也有两条记录
aaa-1000 888888
aaa-1000 999999想要查询出
aaa-1000 1580000000 888888
aaa-1000 1580000001 999999
这样的查询结果sql语句该如何写?
表a:
order_id tel
a中现有一个订单有两条记录
aaa-1000 1580000000
aaa-1000 1580000001
表b:
order_id pp_id
b中对应订单号也有两条记录
aaa-1000 888888
aaa-1000 999999想要查询出
aaa-1000 1580000000 888888
aaa-1000 1580000001 999999
这样的查询结果sql语句该如何写?
select a.order_id,a.tel,b.pp_id from
(select order_id,tel,rownum num from a)ta,
(select order_id,pp_id,rownum num form b) tb
where ta.order_id=tb.order_id and ta.num=tb.num
这个能实现
(select order_id, m_id ,row_number() over(order by order_id) rn from order_mid) a
left join (select order_id, tel ,row_number() over(order by order_id) rn from order_tel) b on a.order_id=b.order_id and a.rn=b.rn