Background documentationData Query Locate this document in the navigation structure

 

For a complete syntax description of the SQL statements for data query, see Data Query in the SQL reference manual. Below are just a few examples of key SQL statements for data query.

Prerequisites

You can use the demo data for the SQL tutorial. Start the Database Studio as database administrator MONA with the password RED and log on to demo database DEMODB: Logging On to a Database.

Example

You can use Database Studio to enter and execute SQL statements. More information: Working with SQL Statements: Overview

SELECT zip, name, state

  FROM hotel.city

    WHERE name = 'Seattle'

This data query means:

  • Search (SELECT)

  • The zip, name, state columns

  • From the city table of the hotel schema (FROM)

  • For the rows with the city name Seattle (WHERE)

The form of a simple SELECT statement is therefore SELECT... FROM... WHERE....

Result

ZIP

NAME

STATE

20005

Seattle

WA

20019

Seattle

WA

20037

Seattle

WA