You are on page 1of 12

UNIT 2

FUNCTIONS OF My SQL

T.Y.B.COM. SEMESTER – V

SHARVARI KULKARNI
ASSISTANT PROFESSOR,
DEPARTMENT OF MATHEMATICS,
MODEL COLLEGE (AUTONOMOUS),
DOMBIVLI
INDEX
 STRING FUNCTION

 DATE FUNCTIONS

 NUMERIC FUNCTIONS
STRING FUNCTIONS

 LOWER – All alphabets converted to lower case.


SELECT LOWER (‘COLLEGE’);
college
 UPPER - All alphabets converted to upper case.
SELECT UPPER (‘college’);
COLLEGE
 REVERSE - The characters in the text will be in the reverse
order.
SELECT REVERSE (‘college’);
egelloc
STRING FUNCTIONS
 LENGTH – It counts the number of characters including blank.
SELECT LENGTH (‘COLLEGE’); will display 7
SELECT LENGTH (‘GOOD MORNING’); will display 12
 LTRIM – Blank spaces from left side are removed.
SELECT LTRIM (‘-----college’);
college
 RTRIM - Blank spaces from right side are removed.
SELECT RTRIM (‘college----’);
college
STRING FUNCTIONS
 TRIM– It removes blank spaces from both sides.
SELECT TRIM (‘-----college -----’);
college
 LEFT – It gives leftmost mentioned number of characters from
the text.
SELECT LEFT (‘college’, 3);
col
 RIGHT – It gives rightmost mentioned number of characters
from the text.
SELECT RIGHT (‘college’, 3);
ege
STRING FUNCTIONS

 MID – It gives the number of characters with the given position.


1) SELECT MID (‘COLLEGE’,2,3); (2 is position ,3 is number)
OLL
2) SELECT MID (UNIVERSITY,4,3);
VER
 CONCAT – It joins all the arguments in the function.
SELECT CONCAT (‘UNI’,’VER’,’SITY’)
UNIVERSITY
DATE FUNCTIONS
 NOW() – It gives the current system date and time.
SELECT NOW();
2020-09-29 11:25:34
 CURDATE() – It gives the current system date.
SELECT CURDATE();
2020-09-29
 TIME(expr) – It gives time from datetime expression .
SELECT TIME (‘2020-09-29 11:25:34’);
11:25:34
 DATE(expr) – It gives date from datetime expression .
SELECT TIME (‘2020-09-29 11:25:34’);
2020-09-29
DATE FUNCTIONS
 DAY(date) – It gives the day of the month for date.
SELECT DAY(2020-09-29);
29
 MONTH(date) – It gives the month for date.
SELECT DAY(2020-09-29);
9
 YEAR(date) – It gives the year for the date.
SELECT YEAR (2020-09-29);
2020
DATE FUNCTIONS
 DAYNAME(date) – It gives the name of the weekday for the
date.
SELECT DAYNAME (‘2020-09-29’);
TUESDAY

 MONTHNAME(date) – It gives the name of the month for the


date.
SELECT DAYNAME (‘2020-09-29’);
SEPTEMBER
NUMERIC FUNCTIONS
  
ABS(x) – It gives the absolute value of x.
SELECT ABS (‘-8’); will give 8
SELECT ABS (‘8’); will give 8
 POW(x,y)- It gives the value of x to the power y .
SELECT (2,3) will give i.e. 8
 MOD(x,y) – It gives the remainder of the division of x by y.
SELECT MOD(10,3) will give 1
NUMERIC FUNCTIONS

 ROUND(n,d) – It gives the number n rounded to d decimals.


SELECT ROUND (11.76, 1 ); will give 11.8

 SQRT(x)- It gives the square root of x.


SELECT SQRT(9) will give 3
THANK YOU

You might also like