Master MySQL System Functions: Complete Reference with Examples
This article provides a comprehensive overview of MySQL's built‑in functions—including numeric, string, date/time, and aggregation utilities—explaining their usage, parameters, and output with clear examples to help developers write more efficient SQL queries.
Overview
MySQL offers a rich set of built‑in functions that simplify data manipulation, calculation, and formatting, greatly improving database management efficiency.
Numeric Functions
Common numeric functions include:
ABS(x) – returns the absolute value of x .
SQRT(x) – returns the square root of x (NULL for negative numbers).
MOD(a,b) – returns the remainder of a divided by b .
CEIL(x) / CEILING(x) – rounds x up to the nearest integer.
FLOOR(x) – rounds x down to the nearest integer (returns BIGINT).
RAND([seed]) – generates a random number between 0 and 1; providing a seed repeats the sequence.
ROUND(x[,d]) – rounds x to d decimal places (negative d rounds to tens, hundreds, etc.).
SIGN(x) – returns -1, 0, or 1 depending on the sign of x .
POW(x,y) / POWER(x,y) – raises x to the power y (negative exponent returns the reciprocal).
TRIGONOMETRIC FUNCTIONS – SIN(), COS(), TAN() and their inverse functions ( ASIN(), ACOS(), ATAN()).
SELECT ABS(-7), ABS(8), ABS(0); SELECT SQRT(-7), SQRT(9), SQRT(39); SELECT MOD(100,7), MOD(100,10), MOD(9,4.5), MOD(18.3,9); SELECT CEILING(-7.9), CEIL(7.5); SELECT FLOOR(-7.9), FLOOR(7.5); SELECT RAND(), RAND(), RAND(2), RAND(); SELECT ROUND(78.2), ROUND(78.5), ROUND(-78.78,1), ROUND(78.7819,3), ROUND(78.78,-1), ROUND(78.78,-2); SELECT SIGN(-78), SIGN(0), SIGN(78); SELECT POW(10,0), POW(10,1), POW(10,2), POW(10,3), POWER(10,-2); SELECT SIN(1), COS(1), SIN(2), SIN(1)*COS(1)+COS(1)*SIN(1), PI();Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Architecture & Thinking
🍭 Frontline tech director and chief architect at top-tier companies 🥝 Years of deep experience in internet, e‑commerce, social, and finance sectors 🌾 Committed to publishing high‑quality articles covering core technologies of leading internet firms, application architecture, and AI breakthroughs.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
