MySQL Functions: Math & String Guide
MySQL supports various mathematical and string functions, here are some commonly used function examples:
Mathematical function:
- ABS(x) – gives the absolute value of x
- ROUND(x, d) – round x to d decimal places
- SQRT(x) – provides the square root of x
- POWER(x, y) – gives the result of x raised to the power of y.
- CEIL(x) – returns the smallest integer greater than or equal to x.
- FLOOR(x) – returns the largest integer less than or equal to x.
String functions:
- Combine two strings.
- – Returns the length of the string.
- Convert a string to uppercase.
- Convert the string to lowercase.
- Return a substring of the string, starting from the position specified by ‘start’ and with the length specified by ‘length’.
- Replace old_str with new_str in the string.
This is just a small portion of the mathematical and string functions supported by MySQL; you can refer to the official MySQL documentation for more functions and their usage.