Database Design and Development SQL SELECT Learning Intention
Database Design and Development SQL - SELECT
Learning Intention �I will learn how to use SQL to SELECT data from a single table.
SQL �Structured Query Language (SQL) is the language used to manage data in a relational database. �Used to perform database operations to ◦ SELECT data ◦ INSERT data ◦ UPDATE data ◦ DELETE data
SELECTING with SQL �The SELECT statement is used to decide which fields are displayed. �SELECT is followed by the fields, separated by commas or a * to select all fields e. g. SELECT town, resort. Type SELECT *
SELECTING with SQL �The FROM clause is used to specify which database table(s) are needed in the query. e. g. FROM Resort
SELECTING with SQL �WHERE clause states the criteria which must be met. Followed by the field name, an operator ( <, =, > etc) and the information specifying the criteria. �e. g. WHERE resort. Type = “city”
SELECTING with SQL WHERE clause: �Criteria on a Text field: use “ e. g. WHERE resort. Type = “city” �Criteria on a Date/Time field: use # e. g. WHERE check. In. Time < #15: 00#
SELECTING with SQL �ORDER BY clause used to tell the sort order of the results e. g. ORDER BY town ASC, star. Rating DESC
SELECTING with SQL SELECT field 1, field 2, field 3, etc FROM table. Name WHERE field. Name 1 = data AND field. Name 3 = data ORDER BY field 2 ASC, field 4 DESC;
Example �Display the town, resort type and train station details for all resort types of city ordered by town in alphabetical order Field(s) Table(s) Search criteria Sort order town, resort. Type, train. Station Resort resort. Type = “city” town ASC
Searching with SQL �SQL: SELECT town, resort. Type, train. Station FROM Resort WHERE resort. Type = “city” ORDER BY town ASC; ** always end an SQL statement with ;
Pupil Task Complete the following: SQL Booklet Tasks 1 - 3
Success Criteria �I can create SQL SELECT statements to select data from a single table.
- Slides: 13