sql select statement ist359. agenda sql select = most important statement understanding fudgemart...
TRANSCRIPT
![Page 1: SQL Select Statement IST359. Agenda SQL SELECT = Most Important Statement Understanding Fudgemart Select from, where, order by Top and distinct keywords](https://reader036.vdocument.in/reader036/viewer/2022082821/5697bf751a28abf838c8076b/html5/thumbnails/1.jpg)
SQL Select Statement
IST359
![Page 2: SQL Select Statement IST359. Agenda SQL SELECT = Most Important Statement Understanding Fudgemart Select from, where, order by Top and distinct keywords](https://reader036.vdocument.in/reader036/viewer/2022082821/5697bf751a28abf838c8076b/html5/thumbnails/2.jpg)
Agenda
• SQL SELECT = Most Important Statement• Understanding Fudgemart• Select from, where, order by• Top and distinct keywords• Table joins• Column and table aliasing
![Page 3: SQL Select Statement IST359. Agenda SQL SELECT = Most Important Statement Understanding Fudgemart Select from, where, order by Top and distinct keywords](https://reader036.vdocument.in/reader036/viewer/2022082821/5697bf751a28abf838c8076b/html5/thumbnails/3.jpg)
SQL SELECT Reads Data
SELECT col1, col2, ...FROM tableWHERE conditionORDER BY columns
Columns To Display
Table to use
Only return rows
matching this
conditionSort row
output by data in these
columns
![Page 4: SQL Select Statement IST359. Agenda SQL SELECT = Most Important Statement Understanding Fudgemart Select from, where, order by Top and distinct keywords](https://reader036.vdocument.in/reader036/viewer/2022082821/5697bf751a28abf838c8076b/html5/thumbnails/4.jpg)
SELECT Demo
• Basic SELECT–Columns–Where ( AND .vs OR)–Order by–TOP / Distinct
![Page 5: SQL Select Statement IST359. Agenda SQL SELECT = Most Important Statement Understanding Fudgemart Select from, where, order by Top and distinct keywords](https://reader036.vdocument.in/reader036/viewer/2022082821/5697bf751a28abf838c8076b/html5/thumbnails/5.jpg)
SELECT
HOW WE SAY IT1. SELECT (Projection)2. TOP/ DISTINCT3. FROM4. WHERE5. ORDER BY
HOW IT IS PROCESSED1. FROM2. WHERE3. SELECT (Projection)4. ORDER BY5. TOP / DISTINCT
![Page 6: SQL Select Statement IST359. Agenda SQL SELECT = Most Important Statement Understanding Fudgemart Select from, where, order by Top and distinct keywords](https://reader036.vdocument.in/reader036/viewer/2022082821/5697bf751a28abf838c8076b/html5/thumbnails/6.jpg)
Fudgemart – Conceptual
![Page 7: SQL Select Statement IST359. Agenda SQL SELECT = Most Important Statement Understanding Fudgemart Select from, where, order by Top and distinct keywords](https://reader036.vdocument.in/reader036/viewer/2022082821/5697bf751a28abf838c8076b/html5/thumbnails/7.jpg)
Fudgemart - Internal
![Page 8: SQL Select Statement IST359. Agenda SQL SELECT = Most Important Statement Understanding Fudgemart Select from, where, order by Top and distinct keywords](https://reader036.vdocument.in/reader036/viewer/2022082821/5697bf751a28abf838c8076b/html5/thumbnails/8.jpg)
JOINS
• JOINS let you combine data from more than one table into your query output
• Most of the time you join on PK-FK pairsSELECT *
FROM tableaJOIN tableb ON acol =
bcol
![Page 9: SQL Select Statement IST359. Agenda SQL SELECT = Most Important Statement Understanding Fudgemart Select from, where, order by Top and distinct keywords](https://reader036.vdocument.in/reader036/viewer/2022082821/5697bf751a28abf838c8076b/html5/thumbnails/9.jpg)
Demo – Table Joins
• Select JOINS– Inner / Equijoin• Basic join type
–Table and Column Aliasing• Makes it easier to know what comes from where
–Outer joins (Left / Right)• Include non-matching records across joins
–Multi-table joins
![Page 10: SQL Select Statement IST359. Agenda SQL SELECT = Most Important Statement Understanding Fudgemart Select from, where, order by Top and distinct keywords](https://reader036.vdocument.in/reader036/viewer/2022082821/5697bf751a28abf838c8076b/html5/thumbnails/10.jpg)
Work in Groups. Try these.
1. All Employees working in the ‘Hardware’ department making less than $15/hr
2. Names and retail prices of the top 5 products3. Product name, product wholesale price , and
vendor name for products supplied by vendor ‘Mikee’
4. List of employee names and their supervisor’s names.