A full description of the syntax used in the SQL statements for data queries is provided under Data Query in the Reference Manual.
The following section uses examples to explain a few of the key SQL statements for data queries.
You need the HOTELDB_SIMPLE version of the model database HOTELDB.
Start the SQL Studio query tool as the database administrator MONA with the password RED.
SELECT zip, name, state
FROM city
WHERE name = 'Washington'
This means:
· Find (SELECT)
· The columns zip, name, state
· From the table city (FROM)
· For the rows with the city name Washington (WHERE)
A simple SELECT statement, therefore, is structured as follows:
SELECT.....
FROM.......
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