據我所知, Null 無法與任何東西相提并論。但是在下面的示例中以不同的方式獲得結果。有人可以幫我理解嗎?
Create table t1 (c1 number);
Insert into T1(C1) Values(1);
Insert into T1(C1) Values(NULL);
Insert into T1(C1) Values(1);
Insert into T1(C1) Values(NULL);
Insert into T1(C1) Values(1);
create table t2 (c2 number);
Insert into T2(C2) Values(1);
Insert into T2(C2) Values(NULL);
Insert into T2(C2) Values(1);
Insert into T2(C2) Values(NULL);
Insert into T2(C2) Values(1);
Insert into T2(C2) Values(NULL);
Insert into T2(C2) Values(1);
select * from t1;
1
NULL
1
NULL
1
select * from t2
1
NULL
1
NULL
1
NULL
1
select * from t1 inner join t2 on(t1.c1=t2.c2);
C1 C2
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
請找到結果集的附件影像。
uj5u.com熱心網友回復:
請參閱此處以了解有關聯接的更多資訊
視頻在這里
uj5u.com熱心網友回復:
就內部聯接或(SQL Server 中的默認聯接)而言,NULL 沒有太大意義。您將獲得 12 條記錄,因為表 t1 中有 3 條記錄并乘以 4 條記錄表 t2。您將使用不同的值獲得不同的結果。
如果它是左/右/交叉連接,則 Null 會產生影響。這里有一些其他的查詢。還要考慮以下查詢。
select * from t1 inner join t2 on(t1.c1=t2.c2); --12
select * from t1 left join t2 on(t1.c1=t2.c2); --14 ( 2 null records considered from table t1)
select * from t1 right join t2 on(t1.c1=t2.c2); --15 ( 3 -null records considered from table t2)
select * from t1 cross join t2 --35 (5x7)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/419555.html
標籤:
上一篇:自定義列選擇谷歌腳本
