1 / 8

Good Afternoon

Good Afternoon. Joining. By using join, we can retrieve data from two or more tables based on logical relationships between the tables. A join condition defines the way two tables are related in a query by:

brady-boyer
Download Presentation

Good Afternoon

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Good Afternoon

  2. Joining • By using join, we can retrieve data from two or more tables based on logical relationships between the tables. • A join condition defines the way two tables are related in a query by: • Specifying the column from each table to be used for the join. A typical join condition specifies a foreign key from one table and its associated key in the other table. • Specifying a logical operator (=,<>,and so on) to be used in comparing values from the columns.

  3. Types of Join • Inner join • Outer join • Left outer join • Right outer join • Cross join

  4. Inner Join Inner join extracts only matching records from tables matched on a single column. Syntax: Select <col name,…..> from <table1 name> JOIN <table 2 name> ON <Primary key = foreign key> [where <condition>] Ex: select productid, suppliers.suppliersid, companyname from suppliers join products on (suppliers.supplierid=products.supplierid)

  5. Left Outer Join Left outer join extracts all rows from the first-named table. Unmatched rows in the right table do not appear. Syntax: Select <col name,…..> from <table1 name> LEFT OUTER JOIN <table 2 name> ON <Primary key = foreign key> [where <condition>] Ex: select productid, suppliers.suppliersid, companyname from suppliers left outer join products on (suppliers.supplierid=products.supplierid)

  6. Right Outer Join Right outer join extracts all rows from the second-named table. Unmatched rows in the left table do not appear. Syntax: Select <col name,…..> from <table1 name> RIGHT OUTER JOIN <table 2 name> ON <Primary key = foreign key> [where <condition>] Ex: select productid, suppliers.suppliersid, companyname from suppliers right outer join products on (suppliers.supplierid=products.supplierid)

  7. Cross Join It is a join whose result set includes one row for each possible pairing of rows from the two tables. Syntax: Select <col name,…..> from <table1 name> CROSS JOIN <table 2 name> ON <Primary key = foreign key> [where <condition>] Ex: select productid, suppliers.suppliersid, companyname from suppliers cross join products on (suppliers.supplierid=products.supplierid)

More Related