BrainDump
  Home arrow BrainDump arrow Page 5 - All About SQL Functions
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 
IBM Developerworks
 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

All About SQL Functions
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2007-12-17

    Table of Contents:
  • All About SQL Functions
  • More Aggregate Functions
  • STDEV
  • Scalar Functions
  • Mid(c,start[,end]
  • Round(c,decimals)

  • 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

    The Web Buyer's Guide is your best source for white papers on a wide range of IT products and services. This Week's Featured White Papers: Protecting Web Applications from Attack and Misuse by Citrix Systems

    All About SQL Functions - Mid(c,start[,end]
    (Page 5 of 6 )

    The Mid function extracts a certain number of characters from a text field. There are three parts to the Mid function:

    • String: The string from which you wish to extract data. If the string is I Hate You and you want the word You, you could start with the word HATE for your string.

    • Start: Where you want the start of the extraction to begin. For instance, if you wanted the word YOU from the string I Hate You, you could put your string as Hate and your start as 6 (the space between hate and you counts as one)

    • Length: How many characters to return. If you wanted the word YOU, this would be 3.


    Select Mid([Luke Breadslicer],6,5) as SampleColumn From Employees;

    The above code would create a column named SampleColumn and display the word: Bread.

    LEN(c)

    The Len function counts the length of the string you specify.


    Select Len([Luke Breadslicer]) as SampleColumn From Employees;

    The above would create a column named SampleColumn and display the count of the characters in the string Luke Breadslicer, which in this case would be 16 (including the space).

    Left(c,number_of_char)

    The Left function returns a string, starting from the left and working its way to the right, of however many places you tell it. I will use the string Luke Breadslicer in the example below:


    Select Left([Luke Breadslicer], 4) as SampleColumn;

    Again, this creates a column named SampleColumn, and displays the string Luke.

    Right(c,number_of_char)

    As you can probably guess, the Right function works the in same way as the Left function, only from the opposite end. If you specify a number larger than the string, it returns the entire string.


    Select Right([Luke], 3) as SampleColumn from Employees;

    This would return a column named SampleColumn and display the data: Uke

    More BrainDump Articles
    More By James Payne


     

       

    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...

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




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