By : Dhirendra Chauhan
“String “
Function
“String “
Function
1. UPPER /UCASE()
2. LOWER/LCASE()
3. LTRIM()
4. RTRIM
5. TRIM()
6. LENGTH()
7. LEFT( )
8. RIGHT()
9. INSTR()
10. INITCAP()
11. CONCAT()
12. SUBSTR / SUBSTRING /
MID()
13. POSITION()
14. CHAR()
UPPER() / UCASE()
Upper() Function Convert a string Small
to upper-case:
Syntax Example
SELECT UCASE(Col_Name)
FROM table_name;
SELECT UCASE(Name)
FROM Employees1;
OUTPUT
Lower() / LCASE()
Lower() Function Convert a string upper
to Small-case:
Syntax Example
SELECT LCASE(Col_Name)
FROM table_name;
SELECT LCASE(Name)
FROM Employees1;
OUTPUT
LTRIM()
The LTRIM() function removes leading
spaces from a string
Syntax Example
SELECT LTRIM(Col_Name)
FROM table_name;
SELECT LTRIM(Name)
FROM Employees1;
OUTPUT
RTRIM()
The RTRIM() function removes trailing
spaces from a string.
Syntax Example
SELECT RTRIM(Col_Name)
FROM table_name;
SELECT RTRIM(Name)
FROM Employees1;
OUTPUT
TRIM()
The TRIM() function removes leading and
trailing spaces from a string.
Syntax Example
SELECT TRIM(Col_Name)
FROM table_name;
SELECT TRIM(Name)
FROM Employees1;
OUTPUT
LENGTH()
The LENGTH() function returns the length of a
string (in bytes).
Syntax Example
SELECT Length(Col_Name)
FROM table_name;
SELECT Length(Name)
FROM Employees1;
OUTPUT
LEFT(string, Number of Char)
The LEFT() function extracts a number of
characters from a string (starting from
left).
Syntax Example
SELECT LEFT(Col_Name , No_of_Char)
FROM table_name;
SELECT LEFT (Name,3)
FROM Employees1;
OUTPUT
RIGHT(string, Number of Char)
The RIGHT() function extracts a
number of characters from a string
(starting from right).
Syntax Example
SELECT RIGHT(Col_Name ,
Number of Char)
FROM table_name;
SELECT RIGHT(Name,3)
FROM Employees1;
OUTPUT
INSTR()
The INSTR() function returns the position of the first
occurrence of a string in another string.
Syntax Example
SELECT INSTR(string1, string2)
FROM table_name;
SELECT INSTR( NAME, ” i ”)
FROM Employees1;
OUTPUT
INITCAP()
Syntax Example
SELECT INITCAP (string); SELECT INITCAP (“dhirendra chauhan”);
The INITCAP() function sets the first
letter of each word in uppercase, all other
letters in lowercase.
OUTPUT
CONCAT(String1, String2)
The CONCAT() function adds two or
more expressions together.
Syntax Example
SELECT CONCAT(String1,
String2) FROM table_name;
SELECT CONCAT(Name , City)
FROM Employees1;
OUTPUT
SUBSTR(string, start, length)
OR
SUBSTRING(string, start, length)
OR
MID( string, start, length)
These function extracts a
substring from a string
(starting at any position).
Syntax
SELECT SUBSTR/SUBSTRING/MID(string, start, length) FROM table_name;
Example
SELECT SUBSTR(NAME, 3, 4) FROM Employees1;
SELECT SUBSTRING(NAME, 3, 4) FROM Employees1;
SELECT MID(NAME, 3, 4) FROM Employees1;
OUTPUT
POSITION(substring IN string)
The POSITION() function returns the position of the first occurrence
of a substring in a string.
If the substring is not found within the original string, this function
returns 0.
Syntax Example
SELECT POSITION(substring IN string)
FROM table_name;
SELECT POSITION(“a” IN Name)
FROM Employees1;
OUTPUT
The CHAR()
The CHAR() function returns
the character based on the
ASCII code.
Syntax Example
SELECT CHAR(Number) ; SELECT CHAR(65) ;
OUTPUT
THANK
YOU

V23 function-2