BrainDump
  Home arrow BrainDump arrow Page 4 - Beginning SQL the SEQUEL: Working with...
FaxWave - Free Trial.
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
eWeek
 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? 
BRAINDUMP

Beginning SQL the SEQUEL: Working with Advanced SQL Statements
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 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:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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

    PCmover - $15 Off with Coupon Code CJPH7Q

    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.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · This is the second SQL article in my series of Beginning SQL. It covers working with...
       · Even though I use some SQL, these articles give an easy to read overview and...
       · Nice to know that learning SQL, can be fun , literally.
       · Thanks for the kind words; I'm glad you guys enjoyed it.
     

       

    BRAINDUMP ARTICLES

    - Outsourcing: the Hoopla, the Reality
    - MySQL Plays in the Sun
    - All About SQL Functions
    - SQL: Functioning in the Real World
    - More Advanced SQL Statements
    - Beginning SQL the SEQUEL: Working with Advan...
    - Beginning SQL
    - A Look at the VI Editor
    - A Quick Tour of Boo
    - Book Review: Open Source Licensing
    - PGP and GPG: Email for the Practical Parano...
    - Microsoft Continues War on Open Source
    - Secure Remote Desktop Sharing with VNC on Li...
    - A Look at Google Project Hosting
    - What we can Learn from Two Linux vs. Microso...




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway