Monday, 23 October 2023

Join Query count with various scenario

 Assume table t1 and t2 table construct as below:

create table t1(column1 number);

create table t2(column1 number);

Added Rows to t1: 

insert into t1 values(1);

insert into t1 values(1);

insert into t1 values(1);

Added Rows to t2: 

insert into t2 values(1);

insert into t2 values(1); 

select * from t1;

Output:  column1

1

1

1

select * from t2;

Output:  column1

1

1

Join : Inner process count of rows as below:

select * from t1 natural join t2; --Total count of rows are 6

select * from t1 join t2 using (column1); --Total count of rows are 6

select * from t1 cross join t2 ; --Total count of rows are 6

select * from t1  join t2 on (t1.column1=t2.column1); --Total count of rows are 6

Join : Outer process count of rows as below:

select * from t1 left outer join t2 on (t1.column1=t2.column1); --Total count of rows are 6

select * from t1 right outer join t2 on (t1.column1=t2.column1); --Total count of rows are 6

select * from t1 full outer join t2 on (t1.column1=t2.column1); --Total count of rows are 6





No comments:

Post a Comment