QUERYING THE DATABASE: QUERIES and VIEWS
Query: Statement that allows data retrieval
View: A virtual table; a saved query (the SELECT
statement, not the result)
SELECT statement (DML)
- retrieves limited set of data from one or more tables
using criteria specified in the WHERE clause
- often used to perform
calculations on the data selected
- result is a table (columns and
rows)
Single-table example (review):
Current Product List:
all data comes from the Products table
Exercises (review)
- List all orders that were shipped to Spain, showing order
number, customer ID, city, and country, sorted by customer ID (actually,
customer name in the Northwind database).
- Modify the query to show orders shipped to
SYNTAX
SELECT column list
FROM tablename
WHERE criteria
ORDER BY column list