eXtropia: the open web technology company
Technology | Support | Tutorials | Development | About Us | Users | Contact Us
Resources
 ::   Tutorials
 ::   Presentations
Perl & CGI tutorials
 ::   Intro to Perl/CGI and HTML Forms
 ::   Intro to Windows Perl
 ::   Intro to Perl 5
 ::   Intro to Perl
 ::   Intro to Perl Taint mode
 ::   Sherlock Holmes and the Case of the Broken CGI Script
 ::   Writing COM Components in Perl

Java tutorials
 ::   Intro to Java
 ::   Cross Browser Java

Misc technical tutorials
 ::   Intro to The Web Application Development Environment
 ::   Introduction to XML
 ::   Intro to Web Design
 ::   Intro to Web Security
 ::   Databases for Web Developers
 ::   UNIX for Web Developers
 ::   Intro to Adobe Photoshop
 ::   Web Programming 101
 ::   Introduction to Microsoft DNA

Misc non-technical tutorials
 ::   Misc Technopreneurship Docs
 ::   What is a Webmaster?
 ::   What is the open source business model?
 ::   Technical writing
 ::   Small and mid-sized businesses on the Web

Offsite tutorials
 ::   ISAPI Perl Primer
 ::   Serving up web server basics
 ::   Introduction to Java (Parts 1 and 2) in Slovak

 

Introduction to Databases for Web Developers
Between  
Like AND, OR and NOT, the BETWEEN operator is used to modify the WHERE clause. The BETWEEN operator works much like the combination of >=, AND, and <=. The fact is that, such circumstances arose so frequently, that the developers of SQL simply made a shortcut for the operation. Thus, to get a listing of all the employees with salaries between the range of 30,000 and 60,000, you could use the long hand version such as:

    SELECT EMP_NAME, EMP_SALARY
    FROM EMPLOYEES
    WHERE EMP_SALARY >= 30000 AND EMP_SALARY <= 60000;

Or, you could use the BETWEEN operator such as:

    SELECT EMP_NAME, EMP_SALARY
    FROM EMPLOYEES
    WHERE EMP_SALARY BETWEEN  30000 AND 60000;

In either case, you'd get the following results

    EMP_NAME		EMP_SALARY
    -------------------------------
    Lim Sing Yuen	40000
    Loo Soon Keat	50000
    -------------------------------

As you can see, the BETWEEN operator is mainly a convenience operator to allow you to type less. As you might expect, the BETWEEN operator comes with its sister NOT BETWEEN operator. Thus, you could get all the employees who make more than 60,000 or who make less than 45,000 using:

    SELECT EMP_NAME, EMP_SALARY
    FROM EMPLOYEES
    WHERE EMP_SALARY NOT BETWEEN 45000 AND 60000;

In this case, you'd get the following results

    EMP_NAME		EMP_SALARY
    -------------------------------
    Lim Li Chuen	90000
    Lim Sing Yuen	40000
    -------------------------------

Previous | Next | Table of Contents