Summary
Keywords
Full Transcript
There are additional functions that you can use in your SQL query. Numeric functions ABS(x) Absolute value of x LOG(x) Natural logarithm of x POW(x, y) x to the power of y RAND() Random number between 0 (inclusive) and 1 (exclusive) ROUND(x, d) x rounded to d decimal places SQRT(x) Square root of x SELECT POW(4, 2); Returns 16 SELECT SQRT(100); Returns 10 String functions: CONCAT(str1, str2) Concatenates the strings LOWER(s) Lowercase str REPLACE(str, from, to) Replaces all occurrences of from with to, within str SUBSTRING(str, pos, len) Gets a substring starting from pos of length len TRIM(str) Removes leading and trailing whitespace UPPER(str) Uppercase str CURDATE() Returns YYYY-MM-DD CURTIME() Returns HH:MM:SS NOW() Returns YYYY-MM-DD HH:MM:SS DATE(str) Extract the date from the string datetime expression TIME(str) Extract the time from the string datetime expression DAY(str) Returns the day from the string datetime expression MONTH(str) Returns the month from the string datetime expression YEAR(str) Returns the year from the string date or datetime expression HOUR(str) Returns the hour from the string datetime expression MINUTE(str) Returns the minute from the string datetime expression SECOND(str) Returns the seconds from the string datetime expression DATEDIFF(str1, str2) Returns str1 – str2 time difference in number of days TIMEDIFF(str1, str2) Returns str1 – str2 time difference Subscribe to Appficial for more programming videos coming soon. Also, don't forget to click LIKE and comment on the video if it helped you out!
