MySQL Functions: Math & String Guide

MySQL supports various mathematical and string functions, here are some commonly used function examples:

Mathematical function:

  1. ABS(x) – gives the absolute value of x
  2. ROUND(x, d) – round x to d decimal places
  3. SQRT(x) – provides the square root of x
  4. POWER(x, y) – gives the result of x raised to the power of y.
  5. CEIL(x) – returns the smallest integer greater than or equal to x.
  6. FLOOR(x) – returns the largest integer less than or equal to x.

String functions:

  1. Combine two strings.
  2. – Returns the length of the string.
  3. Convert a string to uppercase.
  4. Convert the string to lowercase.
  5. Return a substring of the string, starting from the position specified by ‘start’ and with the length specified by ‘length’.
  6. 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.

bannerAds