MySQL code includes many predefined functions. The list below contains those used more often:
FUNCTION | TYPE | DESCRIPTION |
---|---|---|
ABS() | math | Returns and absolute number |
ADDDATE() | date & time | Adds the interval of the days to the time |
ADDTIME() | date & time | Adds the time to the datetime |
AVG() | aggregate | Returns average value from columns |
BIN() | string | Returns a string representation of binary value |
BIT_COUNT() | math | Returns the number of active bits from a specified number |
BIT_LENGTH() | string | Returns the length of a string as bits |
CEIL() or CEILING() | math | Returns rounded number to the higher value |
CHAR() | string | Returns the string for code values of an integer passed to function |
CHAR_LENGTH() | string | Returns string the length of a string as chars |
CHARSET() | admin | Returns the character set of a specified string |
COLLATION() | admin | Returns the collation set of a specified string |
CONCAT() | string | Concatenates input string returning a resultant string |
CONCAT_WS() | string | Concatenates input strings with separator value |
COUNT() | aggregate | Returns number of rows from a column |
CURRENT_DATE() or CURDATE() | date & time | Displays the current date |
CURRENT_TIME() or CURTIME() | date & time | Displays current time |
DATABASE() | admin | Returns the current database name |
DATE() | date & time | Returns the date part of the specified datetime expression |
DATE_FORMAT() | date & time | Formats the date according to specified format argument |
DAY() or DAYOFMONTH() | date & time | Returns the day of the month from specified expression |
ELT() | string | Returns a string at the indexed number |
EXP() | math | Returns value raised to the given power |
FLOOR() | math | Returns rounded number to the lower value |
HEX() | string | Returns a string representation of a hexadecimal value |
IF() | flow | Evaluates expression and returns a value |
IFNULL() | flow | Checks if the expression is NULL, and returns appropriate value based on the result |
INSERT() | string | Inserts a new string into a string |
INSTR() | string | Returns the position of the first occurrence of a substring |
LCASE() | string | Returns all lower case |
MAX() | aggregate | Returns maximum value from a column |
MIN() | aggregate | Returns minimum value from a column |
MINUTE() | date & time | Returns the minute from specified expression |
MOD() | math | Returns the modulo value from the specified number |
MONTH() | date & time | Returns the month of the current date |
NOW() | date & time | Shows the current date and time |
NULLIF() | flow | Returns NULL if the condition is met, otherwise returns the first passed expression |
OCT() | string | Gives a string representation of an octal value |
POWER() | math | Returns the value of 'X' to the power of 'Y' |
RAND() | math | Produces a random number |
REPEAT() | string | Repeats a string for a number of times specified |
REPLACE() | string | Replaces the string passed from to another one |
REVERSE() | string | Returns a reverse string of an input one |
SECOND() | date & time | Returns the second of the current time |
SPACE() | string | Introduces 'n' spaces into a string |
SQRT() | math | Returns the square root |
STR_TO_DATE() | date & time | Converts specified string (a date and/or time) into the datetime format |
STRCMP() | string | Compares two strings and if they are equal returns '0' |
SUBSTR() | string | Returns substring from a string, given by the position specified |
SUM() | aggregate | Returns sum of values from two or more columns |
TIME() | date & time | Extract time or datetime from specified expression and returns it as a string |
TIMESTAMP() | date & time | Returns the date or datetime expression as a datetime value |
TRIM() | string | Removes leading or trailing characters from a string |
TRUNCATE() | math | Returns the value of specified number up to the desired decimal places |
UPPER() | string | Returns all upper case |
USER() | admin | Returns the current MySQL username and hostname |
VERSION() | admin | Returns the used MySQL version |
YEAR() | date & time | Returns the year from specified expression |
Comments
No comments have been made yet.
Please login to leave a comment. Login now