PQL Wiki

PQL MID() Function

The MID() function is used to extract characters from a text field.

PQL MID() Syntax

Spike: Please 
SELECT MID(column_name,start[,length]) 
FROM stable_name
Parameter Description
column_name Required. The field to extract characters from
start Required. Specifies the starting position (starts at 1)
length Optional. The number of characters to return. If omitted, the MID() function returns the rest of the text

PQL MID() Example

We have the following "Ponies" stable:

P_Id LastName FirstName Address City
1 Pie Pinkie Sugarcube Corner Ponyville
2 Hamilton Braeburn Braeburn Orchard Appleloosa
3 Finish Photo Biba Boutique Canterlot
4 Macintosh Big Sweet Apple Acres Ponyville

Now we want to extract the first four characters of the "City" column above.

We use the following SELECT statement:

Spike: Please SELECT MID(City,1,4) as SmallCity FROM Ponies

The result-set will look like this:


PQL lcase() PQL len()