0% found this document useful (0 votes)
10 views3 pages

MySQL String and Math Functions Guide

The document outlines various MySQL functions including CONCAT, LCASE, UCASE, SUBSTR, LTRIM, RTRIM, LENGTH, LEFT, RIGHT, SUBSTRING, MOD, POWER, ROUND, SQRT, CURDATE, and NOW. Each function is described with its purpose and an example query demonstrating its usage. These functions are essential for manipulating strings, calculating values, and retrieving date and time information in MySQL.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views3 pages

MySQL String and Math Functions Guide

The document outlines various MySQL functions including CONCAT, LCASE, UCASE, SUBSTR, LTRIM, RTRIM, LENGTH, LEFT, RIGHT, SUBSTRING, MOD, POWER, ROUND, SQRT, CURDATE, and NOW. Each function is described with its purpose and an example query demonstrating its usage. These functions are essential for manipulating strings, calculating values, and retrieving date and time information in MySQL.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

MySQL Functions Ch-16

1. Concat
CONCAT function is used to combine two strings or columns
Ex- Select CONCAT (Name,Class) as “Name Class” from Student ;
Two columns will combined
2. LCASE/LOWER
This function is used to convert the string in lower case
Ex- Select Lower (Name) from student;
Name column will be converted in LOWER case
3. UCASE/UPPER
This function is used to convert the string in lower case
Ex- Select UPPER (Name) from student;
Name column will be converted in UPPER case
4. SUBSTR
This function is used to extract a string from a given string.
Select SUBSTR(“INFORMATICS”,5,4);
Its output will be RMAT which means 5th string will be extracted an upto next 4
string.
5. LTRIM
This function is used to remove the spaces of the left side from a given string
Ex- Select LTRIM (“ Informatics practices ”)
In the output left spaces will disappear
6. RTRIM
This function is used to remove the spaces of the left side from a given string
Ex- Select LTRIM (“ Informatics practices ”)
In the output right spaces will disappear
7. LENGTH
This function is used to count the length of the character.
Ex- Select LENGTH (“INFORMATICS”) as “LENGTH”;
Output will be 11
[Link]
This function returns the leftmost number of characters as specified
EX- Select LEFT (“INFORMATICS” ,4);
Output will be INFO
[Link]
This function returns the leftmost number of characters as specified
EX- Select LEFT (“INFORMATICS” ,4);
Output will be TICS
[Link]
This function is used to remove the string from a given string as specified.
Ex- Select SUBSTRING (“INFORMATICS”,3,5);
The output will be FORMA
[Link]
This function is used to calculate the modulus
EX-Select MOD (11,4) “MODULUS”;
The output will be 3
When we divide 11/4 the reminder will be 3
[Link]
This function returns the number m raised to nth power
Ex- Select POWER (3,2) “OUTPUT”;
The output will be 3x3=9
[Link]
This function ROUNDS OFF the digit
Ex-Select ROUND(15.193,1) “ROUND”;
The output will be 15.2 which means round off 15 to one decimal place.
[Link]
This function is used to make the square root of the given numbers.
Select SQRT (144) “SQUARE ROOT”;
The output will be 12s
[Link]
This function is used to return the current date.
Ex- CURDATE();
[Link]()
This function is used to return the current date and time
Ex- NOW();

You might also like