我想创建包含两列的表并将数据插入到列中 两个不同的表。我使用查询来生成源表的交叉产品。
以下查询: -
create table test
as
select a.offer_id as offer_id,b.poid as poid
from (select distinct offer_id from table1 limit 5) a, (select distinct poid from table2 limit 5) b;
如何避免跨产品。
答案 0 :(得分:0)
我怀疑你想要这样的东西:
select a.offer_id as offer_id, b.poid as poid
from (select offer_id, row_number() over (order by rand()) as seqnum
from (select distinct offer_id from table1 limit 5) a
) a join
(select poid, row_number() over (order by rand()) as seqnum
from (select distinct poid from table2 limit 5) b
) b
on a.seqnum = b.seqnum;