Joins SQL Server
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
499
On Slideshare
499
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
14
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 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. Sql server joinsASNA C.Akunjulaloos@gmail.comwww.facebook.com/usernametwitter.com/usernamein.linkedin.com/in/profilenamePhonenumber
  • 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. 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. 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. • And a selection from the "Orders" table:SELECT Customers.CustomerName, Orders.OrderIDFROM CustomersINNER JOIN OrdersON Customers.CustomerID= Orders.CustomerIDORDER BY Customers.CustomerName;
  • 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. And a selection from the "Orders" table:SELECT Customers.CustomerName, Orders.OrderIDFROM CustomersLEFT JOIN OrdersON Customers.CustomerID=Orders.CustomerIDORDER BY Customers.CustomerName;
  • 9. RIGHT JOIN• SELECT column_name(s)FROM table_name1RIGHT JOIN table_name2ONtable_name1.column_name=table_name2.column_name
  • 10. ExampleSELECT Customers.CustomerName,Orders.OrderIDFROM CustomersRIGHT JOIN OrdersON Customers.CustomerID= Orders.CustomerIDORDER BY Customers.CustomerName;
  • 11. FULL JOINSELECT column_name(s)FROM table_name1FULL JOIN table_name2ON table_name1.column_name=table_name2.column_name;
  • 12. SELECT Customers.CustomerName,Orders.OrderIDFROM CustomersFULL JOIN OrdersONCustomers.CustomerID=Orders.CustomerIDORDER BY Customers.CustomerName;
  • 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. 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. THANK YOU