BrainDump
  Home arrow BrainDump arrow Page 4 - 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 - NOT BETWEEN
    ( Page 4 of 4 )

    Likewise, if you wanted to see a list of employees whose salary was NOT between $75,000 and $100,000, you would use the NOT BETWEEN statement. This would show you any value lower than $75,000 and higher than $100,000.

    SELECT * FROM EMPLOYEES WHERE SALARY

    NOT BETWEEN $75,000 AND $100,000;

    This would show us the following table:

     

    First Name

    Last Name

    Position

    Salary

    Bruce

    Lee

    Security

    $50,000

    Your

    Name

    Whipping Boy

    $15,000

    ALIAS

    I know what you are thinking. Hot girls in tight leather pants using high-tech weaponry and kicks to the face to spoil the plots of evil-doers worldwide, and still somehow managing to form meaningful relationships. And all within one hour no less.

    Unfortunately, SQL doesn't have any of those. If it did, then every program would be written in SQL. Imagine the database version of World of Warcraft. (Hmmm, now where did I put my medication?)

    The ALIAS statement in SQL comes in handy if you want your column names or even your table itself to show a different name than you originally gave it, without having to change the name of anything. A lot of times you will have other programs that refer to your tables, and if you change the table name or the columns, you have to change all that code. Not good. This is where ALIAS comes in handy.

    SELECT FirstName AS Ninja_Warrior, SALARY AS Meager_Earnings

    FROM EMPLOYEES;

    This would take the first name and salary columns from your employees table and display them with the names Ninja_Warrior and Meager_Earnings, respectively (without actually changing them and causing you many hours of headaches).

    Ninja_Warrior

    Meager_Earnings

    Larry

    $100,000

    Homer

    $75,000

    Homer

    $75,000

    Liza

    $85,000

    Bruce

    $50,000

    You

    $15,000

    Again, you can do the same with your table.

    SELECT FirstName, SALARY

    FROM EMPLOYEES AS EX_EMPLOYEES

    This would return the first name and salary of your employees and show them in a table called EX_EMPLOYEES.

    That covers the first part of the more advanced commands contained within SQL. In the next and final tutorial we will delve into the rest of the advanced statements and transform you into a true SQL Master.



     
     
    >>> 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 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek