1 Intersect: unique rows common in both tables.
select * from one
intersect
select * from two;
Inner Join
select ...
from one a
inner join two b
on a.key = b.key
2 Union: unique rows from both tables.
select * from one
union
select * from two;
Left Join
select ...
from one a
left join two b
on a.key = b.key
select ...
from one a
left join two b
on a.key = b.key
where b.key is NULL
3 Outer Union: all rows from both tables, unique or non-unique are selected.
select * from one
outer union
select * from two;
Outer Join
select ...
from one a
full outer join two b
on a.key = b.key
from one a
full outer join two b
on a.key = b.key
where a.key is NULL
and b.key is NULL
intersect
select * from two;
Inner Join
select ...
from one a
inner join two b
on a.key = b.key
2 Union: unique rows from both tables.
select * from one
union
select * from two;
Left Join
select ...
from one a
left join two b
on a.key = b.key
select ...
from one a
left join two b
on a.key = b.key
where b.key is NULL
3 Outer Union: all rows from both tables, unique or non-unique are selected.
select * from one
outer union
select * from two;
Outer Join
select ...
from one a
full outer join two b
on a.key = b.key
4 Except: unique rows from the first table that are not in the second table.
select * from one
except
select * from two;
Outer Join
select ...except
select * from two;
Outer Join
from one a
full outer join two b
on a.key = b.key
where a.key is NULL
and b.key is NULL
No comments:
Post a Comment