100 likes | 216 Views
SQL Select Statement. IST359 M005. Yang Wang ywang@syr.edu 342 Hinds http://blackboard.syr.edu. Acknowledgements and caveat. These slides draw liberally, with permission, from the following sources: IST359 materials by Prof. Michael Fudge Jr.
E N D
SQL Select Statement IST359 M005 Yang Wang ywang@syr.edu 342 Hinds http://blackboard.syr.edu
Acknowledgements and caveat • These slides draw liberally, with permission, from the following sources: • IST359 materials by Prof. Michael Fudge Jr. • Slides from Murach’s SQL Server 2008 book • Caveat (beware): At best, PowerPoint slides are only a pale limitation of the entirety of a class meeting. In IST359 in particular, the lectures will cover topics beyond what appears in these slides. Don’t rely on them as a substitute for attending class.
Agenda • Understanding Fudgemart • Select from, where, order by • Top and distinct keywords • Table joins • Column and table aliasing
SELECT SELECT {colname [, n] | * } FROM tablename [WHERE condition] [ORDER BY col [ASC | DESC]]
SELECT SELECT employee_id, employee_hourlywage FROM employees WHERE employee_hourlywage > 10 ORDER BY employee_id DESC
Demo #1 • Basic SELECT • Columns • Where ( AND .vs OR) • Order by • Cast / Convert • TOP / Distinct
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
Demo – Table Joins • Select JOINS • Cross (Cartesian product) • Inner / Equijoin • Table and Column Aliasing • Outer joins (Left / Right / Full)