Entering content frame

Background documentation Data Query Locate the document in the library structure

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.

Prerequisites

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.

Example of a Data Query

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

Examples

·        Selecting, Arranging and Renaming Columns

·        Selecting and Arranging Rows

·        Conditions: Comparison, AND, OR, BETWEEN, IN

·        Searching for Character Strings: LIKE

·        Negative Conditions: NOT

·        Creating Groups: GROUP BY, HAVING

·        Arithmetic Operations

·        Functions

·        Set Functions

·        Date and Time Calculations

·        Converting Values

·        Changing Character Strings

·        Information About Character Strings

·        Subquery: Internal Queries

·        Joins: Information From Several Tables

·        Set Operations: UNION, INTERSECT, EXCEPT

 

 

Leaving content frame