For preforming the operations on strings, MySQL has provided some function:
1. UCASE ()/UPPER ()
It converts all characters in the specified string to uppercase. If there are characters in the string that are not letters, they are unaffected by this function.
Syntax:
UCASE( string )
Parameter or Arguments:
string: The string to convert to uppercase.
2. LCASE ()/LOWER ()
It converts all characters in the specified string to lowercase. If there are characters in the string that are not letters, they are unaffected by this function.
Syntax:
LCASE( string )
Parameter or Arguments:
string: The string to convert to lowercase.
3. MID ()/SUBSTRING ()/SUBSTR ()
This function allows you to extract a substring from a string.
Syntax:
MID( string, start_position, [length] )
SUBSTR( string, start_position, [ length ] )
SUBSTRING( string, start_position, [ length ] )
Parameter or Arguments:
string: The string from which Substring is required.
start_position: The position to begin extraction. The first position in the string is always 1.
Length: The number of characters to extract
4. LENGTH ()
This function returns the length of the specified string (measured in bytes).
Syntax:
LENGTH( string )
Parameter or Arguments:
string: The string to return the length for.
5. LEFT ()
LEFT function allows you to extract a substring from a string, starting from the left-most character.
Syntax:
LEFT( string, number_of_characters )
Parameter or Arguments:
string: The string that you wish to extract from.
number_of_characters: The number of characters that you wish to extract from a string starting from the left-most character.
6. RIGHT ()
The RIGHT function allows you to extract a substring from a string, starting from the right-most character.
Syntax:
RIGHT( string, number_of_characters )
Parameter or Arguments:
string: The string that you wish to extract from.
number_of_characters: The number of characters that you wish to extract from a string starting from the right-most character.
7. INSTR ()
INSTR function returns the location of a substring in a string.
Syntax:
INSTR( string, substring )
Parameter or Arguments:
string: The string to search.
substring: The substring to search for in string.
8. LTRIM ()
LTRIM function removes all space characters from the left-hand side of a string.
Syntax:
LTRIM( string )
Parameter or Arguments:
string: The string to trim the space characters from the left-hand side.
9. RTRIM ()
RTRIM function removes all space characters from the right-hand side of a string.
Syntax:
RTRIM( string )
Parameter or Arguments:
string: The string to trim the space characters from the right-hand side.
10. TRIM ()
TRIM function removes all specified characters either from the beginning or the end of a string.
Syntax:
TRIM( [ LEADING | TRAILING | BOTH ] [ trim_character FROM ] string )
Parameter or Arguments:
LEADING: Optional. Removes the trim_character from the front of the string.
TRAILING: Optional. Removes the trim_character from the end of the string.
BOTH: Optional. Removes the trim_character from the front and end of string.
trim_character: Optional. The character that will be removed from the string. If this parameter is omitted, it will remove space characters from the string.
No comments:
Post a Comment