InterBase Quick Start: Part IV - Using the WHERE Clause

From InterBase

Go Up to InterBase Quick Start: Part IV - Retrieving Data

The WHERE clause follows the SELECT and FROM clauses. It must precede the ORDER BY clause. The WHERE clause tests data to see whether it meets certain conditions, so that the SELECT statement returns only the rows that meet the WHERE condition. The WHERE clause allows you to precisely specify which data you want to retrieve.

Image 025.jpg Using WHERE

  1. Enter the following statement to return only rows in which Green is the value of the last_name column.
    SELECT last_name,
           first_name,
           phone_ext
    FROM   Employee
    WHERE  last_name = 'Green'
    

    The query returns one row:

    TutorialWhere1.png
  2. Now modify the previous query: change the equal sign to a greater than sign. The result includes all the rows in which the last name is alphabetically greater than Green.
    SELECT last_name,
           first_name,
           phone_ext
    FROM   Employee
    WHERE  last_name > 'Green'
    

    The query returns 29 rows:

    TutorialWhere2.png

Topics

Advance To: