The
University
of
Vermont

 


SQL Operators. 


 We usually need to filter through the data to find the particular piece that is interesting to us.
To select only the appropriate rows from tables, we use conditional expressions like:
If their last name starts with "K"
If their permanent addres is in California or Utah
If they have more than 100 hours of UG credit

To build these conditional expressions we use database fields, literal values, and operators.
Simple operators:  =    >     < 
    SELECT ENAME FROM EMP WHERE SAL > 2000;

Slightly more complicated:    <>    aka  NOT =   aka   !=
    SELECT ENAME FROM EMP WHERE ENAME != 'SMITH';

Even more interesting: Like  (wildcards are % for 0-many characters or _ for a single unspecified character)
    SELECT ENAME, SAL FROM EMP WHERE ENAME LIKE 'ALL_N';
    SELECT ENAME, SAL FROM EMP WHERE ENAME LIKE 'S%';

And you will need at least 1 function: UPPER
    SELECT ENAME, SAL FROM EMP WHERE UPPER(ENAME) = 'SMITH';
    try this one:
    SELECT ENAME FROM EMP WHERE ENAME = 'smith';
 
 
 

Brought to you through the courtesy of Computing and Information Technology, University of Vermont. Copyright © 1996 The University of Vermont and others. All rights reserved.

The University supports both institutional and personal web pages. The views expressed on personal web pages are strictly those of the author, and are not reviewed or approved by the University of Vermont

Send questions and comments to  Keith.Kennedy@uvm.edu

Read the Webmaster's Policies.
Last page update: November 11, 1998