BrainDump
  Home arrow BrainDump arrow Page 3 - Beginning SQL the SEQUEL: Working with Advanced SQL Statements
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
BRAINDUMP

Beginning SQL the SEQUEL: Working with Advanced SQL Statements
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 11
    2007-09-26


    Table of Contents:
  • Beginning SQL the SEQUEL: Working with Advanced SQL Statements
  • AND and OR...Or OR and And
  • The IN-credible Statement
  • NOT BETWEEN

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Beginning SQL the SEQUEL: Working with Advanced SQL Statements - The IN-credible Statement
    ( Page 3 of 4 )

    By now you may have noticed that there are multiple ways to return the same results in SQL. This is true for all languages really. With the IN statement, you can retrieve a specific set of data you are seeking.

    SELECT * from EMPLOYEES

    WHERE LastName IN ('Sampson','Lee');

    With this line of coding, we are asking the database to return all rows that contain the last names of Sampson and Lee. I know what you are thinking; we could have done that with the OR operator or even the AND operator. Right you are. So why use IN? It's just a matter of preference.

    BETWEEN AND

    You have probably been between a rock and a hard place before, but that's not really what the BETWEEN AND statement is about. If you think about being asked to choose a number between 1 and 100, you're much closer to understanding this bit of SQL. The basic function of the BETWEEN AND statement is to allow you to choose a range of values.

    Let's say you wanted to list all of the employees who made between $75,000 and $100,000. To do so, you would use the following code:

    SELECT * from EMPLOYEES WHERE SALARY

    BETWEEN $75,000 AND $100,000;

    That should bring up the following table:

    First Name

    Last Name

    Position

    Salary

    Homer

    Sampson

    CEO

    $75,000

    Homer

    Sampson

    CFO

    $75,000

    Liza

    Sampson

    CTO

    $85,000

    Larry

    Smith

    President

    $100,000

    Note that in some databases, the BETWEEN AND Statement is taken more literally and would not find $75,000 or $100,000, but instead any number between them. In that event you would change the parameter to between $74,999 and $100,001.



     
     
    >>> More BrainDump Articles          >>> More By James Payne
     

       

    BRAINDUMP ARTICLES

    - Migrating Oracle to PostgreSQL with Enterpri...
    - Demystifying SELinux on Kernel 2.6
    - Yahoo and Microsoft Create Ad Partnership
    - The Advantages of Obscure Open Source Browse...
    - Dell Announces CSI-style Digital Forensics S...
    - Milepost GCC Speeds Open-Source Development
    - Learn These 10 Programming Languages
    - Tomcat Capacity Planning
    - Internal and External Performance Tuning wit...
    - Tomcat Benchmark Procedure
    - Benchmarking Tomcat Performance
    - Tomcat Performance Tuning
    - Wubi: Windows-based Ubuntu Installer
    - Configuring and Optimizing Your I/O Scheduler
    - Linux I/O Schedulers





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek