For a complete syntax description of the SQL statements for data query, see Data Query in the reference manual.
Below are just a few examples of key SQL statements for data query.
You need the HOTEL Demo Schema for the SQL Tutorial.
To log on to the database instance DEMODB, start the SQL Studio query tool as the database administrator MONA with the password RED.
SELECT zip, name, state
FROM hotel.city
WHERE name = 'Washington'
This means that:
· Search (SELECT)
· The zip, name, and state columns
· From the city table of the hotel schema (FROM)
· For the rows with the city name Washington (WHERE)
The form of a simple SELECT statement is therefore:
SELECT.....
FROM.......
WHERE......
WHERE
Result
ZIP |
NAME |
STATE |
20005 |
Washington |
DC |
20019 |
Washington |
DC |
20037 |
Washington |
DC |
· Selecting, Arranging and Renaming Columns
· Selecting and Arranging Rows
· Conditions: Comparison, AND, OR, BETWEEN, IN
· Searching for Character Strings: LIKE
· Creating Groups: GROUP BY, HAVING
· Information About Character Strings
· Joins: Information From Several Tables
· Set Operations: UNION, INTERSECT, EXCEPT