sql joinning.database
TRANSCRIPT
![Page 1: SQL Joinning.Database](https://reader035.vdocument.in/reader035/viewer/2022070516/586f9f2b1a28abcc238b6371/html5/thumbnails/1.jpg)
Welcome
![Page 2: SQL Joinning.Database](https://reader035.vdocument.in/reader035/viewer/2022070516/586f9f2b1a28abcc238b6371/html5/thumbnails/2.jpg)
PRESENTED BY
![Page 3: SQL Joinning.Database](https://reader035.vdocument.in/reader035/viewer/2022070516/586f9f2b1a28abcc238b6371/html5/thumbnails/3.jpg)
SQL JOINS
TOPIC
![Page 4: SQL Joinning.Database](https://reader035.vdocument.in/reader035/viewer/2022070516/586f9f2b1a28abcc238b6371/html5/thumbnails/4.jpg)
CONTENT
![Page 5: SQL Joinning.Database](https://reader035.vdocument.in/reader035/viewer/2022070516/586f9f2b1a28abcc238b6371/html5/thumbnails/5.jpg)
INTRODUCTION
WHAT IS JOINNING???
![Page 6: SQL Joinning.Database](https://reader035.vdocument.in/reader035/viewer/2022070516/586f9f2b1a28abcc238b6371/html5/thumbnails/6.jpg)
A SQL join clause combines columns from one or more tables in a relational database. It creates a set that can be saved as a table or used as it is.
A JOIN is a means for combining columns from one (self-table) or more tables by using values common to each.
DEFINITION
![Page 7: SQL Joinning.Database](https://reader035.vdocument.in/reader035/viewer/2022070516/586f9f2b1a28abcc238b6371/html5/thumbnails/7.jpg)
SQL JOINS
Inner Join
Outer Join
Cross Join
TYPES
![Page 8: SQL Joinning.Database](https://reader035.vdocument.in/reader035/viewer/2022070516/586f9f2b1a28abcc238b6371/html5/thumbnails/8.jpg)
INNER JOINSI.INNER JOIN
Inner join returns only those records that match in both the tables.
Syntax:Select * from table 1 INNER JOIN table 2ONTable 1.Column 1=table 2.Column 1
![Page 9: SQL Joinning.Database](https://reader035.vdocument.in/reader035/viewer/2022070516/586f9f2b1a28abcc238b6371/html5/thumbnails/9.jpg)
SCENARIO
![Page 10: SQL Joinning.Database](https://reader035.vdocument.in/reader035/viewer/2022070516/586f9f2b1a28abcc238b6371/html5/thumbnails/10.jpg)
INNER JOINS
Result:
QUARY:SELECT foods.item_name,foods.item_unit, company.company_name,company.company_city FROM foods INNER JOIN company ON foods.company_id =company.company_id;
ITEM_NAME ITEM_ COMPANY_NAME COMPANY_CITY------------------------- ----- ------------------------- --------------Chex Mix Pcs Akas Foods DelhiCheez-It Pcs Jack Hill Ltd LondonBN Biscuit Pcs Jack Hill Ltd LondonMighty Munch Pcs Foodies. LondonPot Rice Pcs Jack Hill Ltd LondonJaffa Cakes Pcs Order All Boston
![Page 11: SQL Joinning.Database](https://reader035.vdocument.in/reader035/viewer/2022070516/586f9f2b1a28abcc238b6371/html5/thumbnails/11.jpg)
RIGHT JOINSa. Right Outer Join
Right outer join returns all records/rows from right table and from left tablereturns only matched records.
Syntax:
Select * from Table 1Right Outer Join Table 2ONTable 1.Column 1=Table 2.Column 1
![Page 12: SQL Joinning.Database](https://reader035.vdocument.in/reader035/viewer/2022070516/586f9f2b1a28abcc238b6371/html5/thumbnails/12.jpg)
LEFT JOINSb. Left Outer Join
Left outer join returns all records/rows from left table and from right table returns only matched records.
Syntax:
Select * from Table 1Left Outer Join Table 2ONTable 1.Column 1=Table 2.Column 1
![Page 13: SQL Joinning.Database](https://reader035.vdocument.in/reader035/viewer/2022070516/586f9f2b1a28abcc238b6371/html5/thumbnails/13.jpg)
SCENARIO
![Page 14: SQL Joinning.Database](https://reader035.vdocument.in/reader035/viewer/2022070516/586f9f2b1a28abcc238b6371/html5/thumbnails/14.jpg)
RIGHT JOINSQUARY:
SELECT company.company_id,company.company_name, company.company_city,foods.company_id,foods.item_name FROM company RIGHT JOIN foods ON company.company_id = foods.company_id;
RESULT:
COMPANY_ID COMPANY_NAME COMPANY_CITY COMPANY_ID ITEM_NAME ---------- ------------------------- ------------------------- ---------- -------------- 18 Order All Boston 18 Jaffa Cakes 15 Jack Hill Ltd London 15 Pot Rice 15 Jack Hill Ltd London 15 BN Biscuit 15 Jack Hill Ltd London 15 Cheez-It 16 Akas Foods Delhi 16 Chex Mix 17 Foodies. London 17 Mighty Munch Salt n Shake
![Page 15: SQL Joinning.Database](https://reader035.vdocument.in/reader035/viewer/2022070516/586f9f2b1a28abcc238b6371/html5/thumbnails/15.jpg)
LEFT JOINS
RESULT:
QUARY: SELECT company.company_id,company.company_name, company.company_city,foods.company_id,foods.item_name FROM company LEFT JOIN foods ON company.company_id = foods.company_id;
COMPANY_ID COMPANY_NAME COMPANY_CITY COMPANY_ID ITEM_NAME ---------- ------------------------- ------------------------- ---------- -------------- 16 Akas Foods Delhi 16 Chex Mix 15 Jack Hill Ltd London 15 Cheez-It 15 Jack Hill Ltd London 15 BN Biscuit 17 Foodies. London 17 Mighty 15 Jack Hill Ltd London 15 Pot Rice 18 Order All Boston 18 Jaffa Cakes 19 sip-n-Bite. New York
![Page 16: SQL Joinning.Database](https://reader035.vdocument.in/reader035/viewer/2022070516/586f9f2b1a28abcc238b6371/html5/thumbnails/16.jpg)
FULL JOINSc. Full Outer Join
Full outer join combines left outer join and right outer join. This join returns all records/rows from both the tables.
Syntax:
Select * from Table 1Full Outer Join Table 2ONTable 1.Column 1=Table 2.Column 1
![Page 17: SQL Joinning.Database](https://reader035.vdocument.in/reader035/viewer/2022070516/586f9f2b1a28abcc238b6371/html5/thumbnails/17.jpg)
CROSS JOINSIII. Cross Join
This join returns records/rows that are multiplication of record number from both the tables means each row on left table will related to each row of right table.
Syntax:
Select * from Table 1Cross Join Table 2
![Page 18: SQL Joinning.Database](https://reader035.vdocument.in/reader035/viewer/2022070516/586f9f2b1a28abcc238b6371/html5/thumbnails/18.jpg)
SCENARIO
![Page 19: SQL Joinning.Database](https://reader035.vdocument.in/reader035/viewer/2022070516/586f9f2b1a28abcc238b6371/html5/thumbnails/19.jpg)
FULL JOINSQUARY:
SELECT a.company_id AS "a.ComID", a.company_name AS "C_Name", b.company_id AS "b.ComID", b.item_name AS "I_Name" FROM company a FULL OUTER JOIN foods b ON a.company_id = b.company_id;
RESULT:a.ComID C_Name b.ComID I_Name---------- ------------------------- ---------- ------------- 16 Akas Foods 16 Chex Mix 15 Jack Hill Ltd 15 Cheez-It 15 Jack Hill Ltd 15 BN Biscuit 17 Foodies. 17 Mighty Munch 15 Jack Hill Ltd 15 Pot Rice 18 Order All 18 Jaffa Cakes Salt n Shake 19 sip-n-Bite.
![Page 20: SQL Joinning.Database](https://reader035.vdocument.in/reader035/viewer/2022070516/586f9f2b1a28abcc238b6371/html5/thumbnails/20.jpg)
CROSS JOINSQUARY:SELECT foods.item_name,foods.item_unit, company.company_name,company.company_city FROM foods CROSS JOIN company; RESULT:
![Page 21: SQL Joinning.Database](https://reader035.vdocument.in/reader035/viewer/2022070516/586f9f2b1a28abcc238b6371/html5/thumbnails/21.jpg)
Any Query?????
![Page 22: SQL Joinning.Database](https://reader035.vdocument.in/reader035/viewer/2022070516/586f9f2b1a28abcc238b6371/html5/thumbnails/22.jpg)
Hey Buddy…..