eXtropia: the open web technology company
Technology | Support | Tutorials | Development | About Us | Users | Contact Us
 ::   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
Suppose you don't want all of the data for all of the rows in a table. Instead, perhaps you only want data for rows that match some criteria. For example, perhaps I want to see the data for the employees, but I only am interested in seeing the data for the employees who make over $45,000 per year.

Well, SQL provides the "where" clause for just these circumstances. The "where" clause allows you to specify conditions that a column cell must meet if it is to be considered a match and be returned in the results. In SQL syntax terminology, the WHERE clause is called the predicate.

The generic syntax of the WHERE clause looks something like the following:

    SELECT column_name
    FROM table_name
    WHERE where_clause;

Consider the following case in which we ask the database to return only the rows in the SALES table in which the Employee number is equal to "101"

     SELECT *
     WHERE E_NUM = 101;

In this case, the database would return the following:

001	001	1		99.99		101	102
003	002    	1		865.99		101	103

[Spacer] The WHERE clause can be used in conjunction with various testing operators besides the "=" sign. Specifically, you can use the ">", "<", "<=", or ">=" operators to select ranges. Thus, to get a report of all the employees making more that 45,000 per year, you might use the following:

    SELECT *
    WHERE EMP_SALARY > 45000;

If you are comparing a column of the CHARACTER data type, you can place the match string in single quotes ('').

For example, to find out Rick Tan's phone number from the CLIENTS table, you might use:

     WHERE C_NAME = 'Rick Tan';

In this case, the database would return the following:

    649-2038		Rick Tan

Note that although SQL is generally case insensitive, when you are matching CHARACTERS using the single quotes, you must be aware of case. Thus, WHERE name = "CHRIS" would not return the same as WHERE name = "Chris".

Previous | Next | Table of Contents