You are on page 1of 4

create table temp3

( id int)

insert into temp3


values (1),(1),(null)

create table temp


( id int)

insert into temp values (8)


values (1),(1),(null)

select * from temp


id
1
1
null

select * from temp3


id
1
1
NULL

select * from temp


select * from temp3

select a.id,b.id from temp a inner join temp3 b on a.id= b.id;

select a.id,b.id from temp a , temp3 b on a.id= b.id;

id id
1 1
1 1
1 1
1 1

select a.id,b.id from temp a left outer join temp3 b on a.id= b.id
id id
1 1
1 1
1 1
1 1
NULL NULL
select a.id,b.id from temp a right outer join temp3 b on a.id= b.id
id id
1 1
1 1
1 1
1 1
NULL NULL

select a.id,b.id from temp a full outer join temp3 b on a.id= b.id

1 1
1 1
1 1
1 1
NULL NULL
NULL NULL
select a.id,b.id from temp3 a full outer join temp b on a.id= b.id
1 1
1 1
1 1
1 1
NULL NULL
NULL NULL
select a.id,b.id from temp3 a cross join temp b

select * from emp


select * from emp1

select * from emp -7 records


A
A
A
A
A
B
B

select * from emp1 2 records


A
B
question what will o/p below querires

select a1.a from emp a1 inner join emp1 b2 on a1.a = b2.b


o/p
A
A
A
A
A
B
B
select a1.a,b2.b from emp a1 inner join emp1 b2 on a1.a = b2.b

A A
A A
A A
A A
A A
B b
B b

select b2.b from emp a1 inner join emp1 b2 on a1.a = b2.b o/p- 7
select a1.a,b2.b from emp a1 cross join emp1 b2

14 records
A A
A A
A A
A A
A A
B A
B A
A b
A b
A b
A b
A b
B b
B b
select a1.a from emp a1 right outer join emp1 b2 on a1.a = b2.b

A
A
A
A
A
B
B

select a1.a from emp a1 left outer join emp1 b2 on a1.a = b2.b

A
A
A
A
A
B
B

select b2.a from emp1 a1 full outer join emp b2 on a1.b = b2.a
select b2.a from emp1 a1 left outer join emp b2 on a1.b = b2.a

create table temp1


(
id int)

create table temp2


(
id int)
*/

/*insert temp1 values (1),(null),(3),(4)

insert temp2 values (1),(2),(null),(4),(5),(6)*/

select * from temp1


id
1
NULL
3
4

select * from temp2


id
1
2
NULL
4
5
6
select * from temp1
select * from temp2
select a.id from temp1 a right outer join temp2 b on a.id = b.id

select a.id ,b.id from temp1 a inner join temp2 b on a.id = b.id
1 1
4 4
select a.id from temp1 a left outer join temp2 b on a.id = b.id
1
NULL
3
4

select a.id from temp1 a right outer join temp2 b on a.id = b.id
id
1
NULL
NULL
4
NULL
NULL

select b.id from temp1 a left outer join temp2 b on a.id = b.id

1
NULL
NULL
4

select b.id from temp1 a right outer join temp2 b on a.id = b.id

1
2
NULL
4
5
6

You might also like