[英]Merging two tables without any join key
我目前在嘗試合並兩個表時遇到一些困難。
例:
表格1:
Sylvester
Kim
Charlotte
Jessica
Theodor
表_2:
01-01-2014
02-01-2014
03-01-2014
etc..
table_1中的每個名稱都需要與table_2中的每個日期合並。
結果:
Table_3(名稱,日期):
Sylvester, 01-01-2014
Sylvester, 02-01-2014
Sylvester, 03-01-2014
Charlotte, 01-01-2014
Charlotte, 02-01-2014
Charlotte, 03-01-2014
and etc...
我試圖做一個合並語句,但無法使其生效。 你們中有誰知道如何解決這個問題?
謝謝。
您想要cross join
:
select t1.*, t2.*
from table_1 t1 cross join
table_2 t2;
如果確實需要在另一個表create table table_3 as
在select
之前放置create table table_3 as
。
嘗試
SELECT * INTO Table_3 FROM Table_1, Table_2
從技術上說,逗號是一個聯接,可能無法滿足您的目的,但是它將從Table_1和Table_2中選擇記錄的每種組合,並將它們插入到Table_3中
編輯:T-SQL解決方案不是Oracle。 對於那個很抱歉
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.