Learn SQL Join,Inner Join, Outer Join
For Example:
Table A have 12( 8+4) entries, 8 entries have valid relation with B
Table B have 80(77+3) entries , 77 entries have valid relation with A.
then the return amount of join is :
cross join : 12*80
inner join : 77
full outer join : 77+4+3
left outer join: 77 + 4
right outrer join: 77 + 3
INNER Join code as the following:
Select * from A a, B b where a.categoryID = b.categoryID;
equals:
Select * from A a inner join B b on a.categoryID = b.categoryID;
OUTER Join code as the following
select * from A a full(left/right) outer join B b on a on a.categoryID = b.categoryID;
left/right outer join claus specific for MSSQL:
Select * from A a, B b where a.categoryID *= bcategoryID;
elect * from A a, B b where a.categoryID =* b.categoryID;
left/right outer join claus specific for Oracle:
Select * from A a, B b where a.categoryID = b.categoryID(+);
Select * from A a, B b where a.categoryID (+) = b.categoryID;
Good Resources:
http://www.w3schools.com/sql/sql_join.asp
http://www.techonthenet.com/sql/joins.htm
Table A have 12( 8+4) entries, 8 entries have valid relation with B
Table B have 80(77+3) entries , 77 entries have valid relation with A.
then the return amount of join is :
cross join : 12*80
inner join : 77
full outer join : 77+4+3
left outer join: 77 + 4
right outrer join: 77 + 3
INNER Join code as the following:
Select * from A a, B b where a.categoryID = b.categoryID;
equals:
Select * from A a inner join B b on a.categoryID = b.categoryID;
OUTER Join code as the following
select * from A a full(left/right) outer join B b on a on a.categoryID = b.categoryID;
left/right outer join claus specific for MSSQL:
Select * from A a, B b where a.categoryID *= bcategoryID;
elect * from A a, B b where a.categoryID =* b.categoryID;
left/right outer join claus specific for Oracle:
Select * from A a, B b where a.categoryID = b.categoryID(+);
Select * from A a, B b where a.categoryID (+) = b.categoryID;
Good Resources:
http://www.w3schools.com/sql/sql_join.asp
http://www.techonthenet.com/sql/joins.htm