1. UCASE() Function
The UCASE() function converts the value of selected field to uppercase.
Syntax:
SELECT UCASE(Column_name)
FROM table_name;
Example : Query using UCASE() Function.
Consider the following table titled as
'Stationary', which contains the information of products.
Write a query to convert values in 'Name' to uppercase, from table 'Stationary'.
| ID | Name | Quantity | Price |
|---|
| 1 | Pen | 10 | 200 |
| 2 | Ink | 15 | 300 |
| 3 | Notebook | 20 | 400 |
| 4 | Pencil | 30 | 150 |
SELECT UCASE (Name) AS NAME
FROM Stationary;
The result is shown in the following table.
2. LCASE() Function
The SQL LCASE() Function converts the value of selected field to lowercase.
Syntax:
SELECT LCASE(Column_name)
FROM table_name;
Example : Query using LCASE() Function.
Consider the following table titled as
'Stationary', which contains the information of products.
Write a query to convert values in 'Name' to lowercase, from table 'Stationary'.
| ID | Name | Quantity | Price |
|---|
| 1 | Pen | 10 | 200 |
| 2 | Ink | 15 | 300 |
| 3 | Notebook | 20 | 400 |
| 4 | Pencil | 30 | 150 |
SELECT LCASE(Name) AS NAME
FROM Stationary;
The result is shown in the following table.
| ID | Name | Quantity | Price |
|---|
| 1 | pen | 10 | 200 |
| 2 | ink | 15 | 300 |
| 3 | notebook | 20 | 400 |
| 4 | pencil | 30 | 150 |
3. MID() Function
The SQL MID() Function is used to extract characters from a selected field from table.
Syntax:
SELECT MID(Column_name, starting_point, total length) AS Some_name
FROM table_name;
Example : Query using MID() Function.
Consider the following table titled as
'Stationary', which contains the information of products.
Write a query to extract characters from column 'Name' to from table 'Stationary'. Where, starting point of a character is 2 and total length is 3.
| ID | Name | Quantity | Price |
|---|
| 1 | Pen | 10 | 200 |
| 2 | Ink | 15 | 300 |
| 3 | Notebook | 20 | 400 |
| 4 | Pencil | 30 | 150 |
SELECT MID(Name, 2, 3) AS NAME
FROM Stationary;
The result is shown in the following table.
4. LEN() Functions
The SQL LEN() function returns the length of the characters of selected column (text field)
Syntax:
SELECT LEN(column_name)
FROM table_name;
Example : Query using LEN() Function.
Consider the following table titled as
'Stationary', which contains the information of products.
Write a query to extract length of characters of column 'Name' of table 'Stationary'.
| ID | Name | Quantity | Price |
|---|
| 1 | Pen | 10 | 200 |
| 2 | Ink | 15 | 300 |
| 3 | Notebook | 20 | 400 |
| 4 | Pencil | 30 | 150 |
SELECT LEN(Name) AS Length_of_NAME
FROM Stationary;
The result is shown in the following table.
| Name | Length_of_NAME |
|---|
| Pen | 3 |
| Ink | 3 |
| Notebook | 8 |
| Pencil | 6 |