Home arrow BrainDump arrow Page 5 - All About SQL Functions

Mid(c,start[,end] - BrainDump

In the last tutorial we left off with the SUM(column) function. In this article we will cover the remaining Aggregate Functions and the Scalar Functions. We might even make some fat jokes, some mama jokes, and as always, some nerd jokes.

  1. All About SQL Functions
  2. More Aggregate Functions
  3. STDEV
  4. Scalar Functions
  5. Mid(c,start[,end]
  6. Round(c,decimals)
By: James Payne
Rating: starstarstarstarstar / 8
December 17, 2007

print this article



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.


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


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.


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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Apple Founder Steve Jobs Dies
- Steve Jobs` Era at Apple Ends
- Google's Chrome Developer Tool Updated
- Google's Chrome 6 Browser Brings Speed to th...
- New Open Source Update Fedora 13 is Released...
- Install Linux with Knoppix
- iPad Developers Flock To SDK 3.2
- Managing a Linux Wireless Access Point
- Maintaining a Linux Wireless Access Point
- Securing a Linux Wireless Access Point
- Configuring a Linux Wireless Access Point
- Building a Linux Wireless Access Point
- Migrating Oracle to PostgreSQL with Enterpri...
- Demystifying SELinux on Kernel 2.6
- Yahoo and Microsoft Create Ad Partnership

Developer Shed Affiliates


Dev Shed Tutorial Topics: