Your SlideShare is downloading. ×
0
Disclaimer: This presentation is prepared by trainees ofbaabtra as a part of mentoring program. This is not officialdocume...
Sql server joinsASNA C.Akunjulaloos@gmail.comwww.facebook.com/usernametwitter.com/usernamein.linkedin.com/in/profilenamePh...
Sql joinsThe JOIN keyword is used in an SQL statement to querydata from two or more tables, based on a relationshipbetween...
Different SQL JOINs• INNER JOIN: Return rows when there is at least one matchin both tables• LEFT JOIN: Return all rows fr...
Inner joinSELECT column_name(s)FROM table_name1INNER JOIN table_name2ONtable_name1.column_name=table_name2.column_name;• E...
• And a selection from the "Orders" table:SELECT Customers.CustomerName, Orders.OrderIDFROM CustomersINNER JOIN OrdersON C...
Left joinSELECT column_name(s)FROM table_name1LEFT JOIN table_name2ONtable_name1.column_name=table_name2.colmn_nameExample...
And a selection from the "Orders" table:SELECT Customers.CustomerName, Orders.OrderIDFROM CustomersLEFT JOIN OrdersON Cust...
RIGHT JOIN• SELECT column_name(s)FROM table_name1RIGHT JOIN table_name2ONtable_name1.column_name=table_name2.column_name
ExampleSELECT Customers.CustomerName,Orders.OrderIDFROM CustomersRIGHT JOIN OrdersON Customers.CustomerID= Orders.Customer...
FULL JOINSELECT column_name(s)FROM table_name1FULL JOIN table_name2ON table_name1.column_name=table_name2.column_name;
SELECT Customers.CustomerName,Orders.OrderIDFROM CustomersFULL JOIN OrdersONCustomers.CustomerID=Orders.CustomerIDORDER BY...
If this presentation helped you, please visit ourpage facebook.com/baabtra and like it.Thanks in advance.www.baabtra.com |...
Contact UsEmarald Mall (Big Bazar Building)Mavoor Road, Kozhikode,Kerala, India.Ph: + 91 – 495 40 25 550NC Complex, Near B...
THANK YOU
Joins SQL Server
Joins SQL Server
Joins SQL Server
Joins SQL Server
Joins SQL Server
Upcoming SlideShare
Loading in...5
×

Joins SQL Server

228

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
228
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
20
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Joins SQL Server"

  1. 1. Disclaimer: This presentation is prepared by trainees ofbaabtra as a part of mentoring program. This is not officialdocument of baabtra –Mentoring PartnerBaabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt .Ltd
  2. 2. Sql server joinsASNA C.Akunjulaloos@gmail.comwww.facebook.com/usernametwitter.com/usernamein.linkedin.com/in/profilenamePhonenumber
  3. 3. Sql joinsThe JOIN keyword is used in an SQL statement to querydata from two or more tables, based on a relationshipbetween certain columns in these tables.Tables in a database are often related to each other withkeys.A primary key is a column (or a combination of columns)with a unique value for each row. Each primary key valuemust be unique within the table. The purpose is to binddata together, across tables, without repeating all of thedata in every table.
  4. 4. Different SQL JOINs• INNER JOIN: Return rows when there is at least one matchin both tables• LEFT JOIN: Return all rows from the left table, even if thereare no matches in the right table• RIGHT JOIN: Return all rows from the right table, even ifthere are no matches in the left table• FULL JOIN: Return rows when there is a match in one ofthe tables
  5. 5. Inner joinSELECT column_name(s)FROM table_name1INNER JOIN table_name2ONtable_name1.column_name=table_name2.column_name;• Example: Below is a selection from the "Customers" table:
  6. 6. • And a selection from the "Orders" table:SELECT Customers.CustomerName, Orders.OrderIDFROM CustomersINNER JOIN OrdersON Customers.CustomerID= Orders.CustomerIDORDER BY Customers.CustomerName;
  7. 7. Left joinSELECT column_name(s)FROM table_name1LEFT JOIN table_name2ONtable_name1.column_name=table_name2.colmn_nameExample: Below is a selection from the "Customers" table:
  8. 8. And a selection from the "Orders" table:SELECT Customers.CustomerName, Orders.OrderIDFROM CustomersLEFT JOIN OrdersON Customers.CustomerID=Orders.CustomerIDORDER BY Customers.CustomerName;
  9. 9. RIGHT JOIN• SELECT column_name(s)FROM table_name1RIGHT JOIN table_name2ONtable_name1.column_name=table_name2.column_name
  10. 10. ExampleSELECT Customers.CustomerName,Orders.OrderIDFROM CustomersRIGHT JOIN OrdersON Customers.CustomerID= Orders.CustomerIDORDER BY Customers.CustomerName;
  11. 11. FULL JOINSELECT column_name(s)FROM table_name1FULL JOIN table_name2ON table_name1.column_name=table_name2.column_name;
  12. 12. SELECT Customers.CustomerName,Orders.OrderIDFROM CustomersFULL JOIN OrdersONCustomers.CustomerID=Orders.CustomerIDORDER BY Customers.CustomerName;
  13. 13. If this presentation helped you, please visit ourpage facebook.com/baabtra and like it.Thanks in advance.www.baabtra.com | www.massbaab.com |www.baabte.com
  14. 14. Contact UsEmarald Mall (Big Bazar Building)Mavoor Road, Kozhikode,Kerala, India.Ph: + 91 – 495 40 25 550NC Complex, Near Bus StandMukkam, Kozhikode,Kerala, India.Ph: + 91 – 495 40 25 550Start up VillageEranakulam,Kerala, India.Email: info@baabtra.com
  15. 15. THANK YOU
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×