1 / 10

SQL Select Statement

SQL Select Statement. IST359. Agenda. SQL SELECT = Most Important Statement Understanding Fudgemart Select from, where, order by Top and distinct keywords Table joins Column and table aliasing. SQL SELECT  Reads Data. Columns To Display. SELECT col1, col2, ... FROM table

kimo
Télécharger la présentation

SQL Select Statement

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SQL Select Statement IST359

  2. Agenda • SQL SELECT = Most Important Statement • Understanding Fudgemart • Select from, where, order by • Top and distinct keywords • Table joins • Column and table aliasing

  3. SQL SELECT  Reads Data Columns To Display SELECTcol1, col2, ... FROMtable WHEREcondition ORDER BY columns Table to use Only return rows matching this condition Sort row output by data in these columns

  4. SELECT Demo • Basic SELECT • Columns • Where ( AND .vs OR) • Order by • TOP / Distinct

  5. SELECT HOW WE SAY IT HOW IT IS PROCESSED FROM WHERE SELECT (Projection) ORDER BY TOP / DISTINCT • SELECT (Projection) • TOP/ DISTINCT • FROM • WHERE • ORDER BY

  6. Fudgemart – Conceptual

  7. Fudgemart - Internal

  8. JOINS • JOINS let you combine data from more than one table into your query output • Most of the time you join on PK-FK pairs SELECT * FROMtablea JOINtablebONacol=bcol

  9. 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

  10. Work in Groups. Try these. • All Employees working in the ‘Hardware’ department making less than $15/hr • Names and retail prices of the top 5 products • Product name, product wholesale price , and vendor name for products supplied by vendor ‘Mikee’ • List of employee names and their supervisor’s names.

More Related