@Backup

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



X10.com - The SuperSite for Home Automation!

NextCard Internet Visa - Apply Now

 
  Categories
Software

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

Next: The INSERT statement

Handling Data with SQL
Learn the basics of SQL's four main data manipulation statements: INSERT, SELECT, UPDATE, and DELETE.

By Gabrielle Gagnon

Fluency in SQL is a valuable asset to anyone who uses a database. In this article, the second half of a two-part primer on SQL, we walk you through four fundamental data manipulation statements--the heart of SQL's functionality--introducing you to comparison operators, selection predicates, and three-valued logic along the way. When you've completed this primer, you will be on your way to becoming a SQL master.

In our previous issue, we concluded by creating a table using the CREATE TABLE statement, an example of a category of SQL statements called data definition language (DDL) statements. DDL statements define database objects such as tables, columns, and views. They don't deal with rows in a table, however, because DDL statements don't handle the actual data that goes into a database. There is another category of SQL statements for doing that: data manipulation language (DML) statements.

There are four basic DML operations in SQL: INSERT, SELECT, UPDATE, and DELETE. Since these are the statements that most SQL users will work with, we'll cover all of them here. In Figure 1, we show a table called EMPLOYEES. Each row corresponds to a specific employee record. Take some time to familiarize yourself with this table; we'll be using it for the rest of our examples.

Gabrielle Gagnon is a freelance programmer and technical writer.

FIGURE 1: This SQL table was created with the CREATE TABLE statement. Each row corresponds to an employee record.

Table 1
LAST_NAME FIRST_NAME HIRE_DATE BRANCH_OFFICE GRADE SALARY
Smith John 06/10/1980 Los Angeles 16 45000.00
Bunyan Paul 07/04/1970 Boston 12 70000.00
Adams John 01/21/1992 Boston 20 100000.00
Smith Pocahontas 04/06/1976 Los Angeles 12 100000.00
Smith Bessie 05/02/1940 Chicago 5 200000.00
Jones Davy 10/10/1970 Boston 8 45000.00
Jones Indiana 02/01/1992 Chicago

Next: The INSERT statement

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.