Get 3.9% APR, Get Instant Credit - Click here!

PC Magazine

  PC Tech

Handling Data with SQL

Introduction

The INSERT statement

The SELECT statement

Defining Selection Criteria

Comparisons and Logical Connectors

Nulls and Three-Valued Logic

The UPDATE statement

The DELETE statement



NEC - Reliability that sells itself.

jobEngine

 
  Categories
Software

Related Stories
SQL: The Universal Database Language
-- 11/3/98

Next: Comparisons and Logical Connectors

Handling Data with SQL
Defining Selection Criteria

Continued from The SELECT statement

In the SELECT statements we've shown so far, we've limited the number of columns in the result table but returned all of the rows. Let's look at how to qualify the SELECT statement so it returns only the rows you want to see:

SELECT columns FROM tables [WHERE predicates] ;

The WHERE clause sets conditions that rows must meet in order to be included in the result table. These conditions are specified in one or more predicates. (A predicate states a possible truth about something.) If the predicate for any given row is true, that row is included in the result table; otherwise it is left out. In SQL statements, predicates are usually expressed through comparisons. For example, if you wanted to see all of the employees whose last name was Jones, you would use the following SELECT statement:

SELECT * FROM EMPLOYEES
   WHERE LAST_NAME = 'Jones' ;

The LAST_NAME = 'Jones' part is the predicate. When executing this statement, SQL compares the value of each row's LAST_NAME to 'Jones'. If an employee's last name is Jones, the predicate is true, and that employee's information will be included in the result table. (See Table 6.)

Next: Comparisons and Logical Connectors

Published as PC Tech Feature in the 11/17/98 issue of PC Magazine.

Elsewhere on ZDNet
Learn SQL Online -- ZD University
Business Software: Databases -- ZD Products

 
 SPONSORED LINKS
@Backup   Your Solid Online Backup Plan. Download Now.
Services   9c/MINUTE LONG DISTANCE, 5c/MINUTE ON SUNDAYS!
STORAGE   Quantum means non-stop business, 24 hours a day
Software   X10.com -- The SuperSite for Home Automation
Books   Bargain Books up to 90% off at barnesandnoble.com
 ZDNET FEATURED LINKS
Downloads   Check out the best new downloads in Reviewer's Raves
Bargains!   Shop the Basement for best buys on computer products
Free Help   Got computing questions? ZDHelp has all the answers!
 MAGAZINE OFFERS
Free Offer   Get a FREE SUBSCRIPTION to Inter@ctive Week

TOP
Copyright (c) 1998 Ziff-Davis Inc.