Understanding SQL Joins: Types, Syntax, and Examples, Slides of Fundamentals of E-Commerce

Learn about sql joins, a powerful feature for retrieving data from multiple tables. Discover the differences between inner and outer joins, and explore a join example using the shop.mdb database.

Typology: Slides

2012/2013

Uploaded on 07/29/2013

masti
masti 🇮🇳

4.5

(10)

121 documents

1 / 7

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Back to SELECT: The Join
Sometimes we want fields from more then
one table. To do this we use a JOIN.
BTW: JET = Join Engine Technology.
Two Types:
INNER: Rows have only fields in one that
match the other.
OUTER: May include some of each with
NULLS for missing values.
Docsity.com
pf3
pf4
pf5

Partial preview of the text

Download Understanding SQL Joins: Types, Syntax, and Examples and more Slides Fundamentals of E-Commerce in PDF only on Docsity!

Back to SELECT: The Join

  • Sometimes we want fields from more then

one table. To do this we use a JOIN.

BTW

: JET = Join Engine Technology.

  • Two Types:
    • INNER: Rows have only fields in one that

match the other.

  • OUTER: May include some of each with

NULLS for missing values.

Joins

  • Must use DOT (.) notation i.e.

TABLE.FIELD

  • Best constructed with a tool (actually all

queries are best constructed with a tool).

  • Most powerful feature in SQL. We

normalize tables for efficiency, joins allowus to view data de-normalized like in aspreadsheet.

Inner Joins

  • In an inner join the rows returned only

include those in which there is a matchingrow or rows from BOTH tables.

  • For example if I have a table of Customers

and Invoices and if there are customers without invoices or invoices without customersthose rows will NOT be included in therows returned from an inner join.

Join Example From Shop.mdb^ Query: SELECT Customer.CustomerID, Customer.NameLast,Customer.NameFirst, Sale.SaleID, Sale.SaleDate,SaleDetail.Quantity, SaleDetail.UnitPrice, Product.ProductNameFROM Product INNER JOIN ((Customer INNER JOIN Sale ONCustomer.CustomerID = Sale.CustomerID) INNER JOIN SaleDetailON Sale.SaleID = SaleDetail.SaleID) ON Product.ProductID =SaleDetail.ProductIDWHERE (((Customer.Voided)=0) AND ((Sale.Voided)=0))ORDER BY Customer.NameLast, Customer.NameFirst;

vAllOrders

: All Orders

Join Example Results