MySQL LOG() function

With one argument, LOG(X) returns the natural logarithm of X. With two arguments, LOG(B,X) returns the logarithm of X to base B.

Using ROUND() with LOG()

SELECT ROUND(LOG(2), 2); -- Output: 0.69
SELECT ROUND(LOG(-2), 2); -- Output: NULL
SELECT ROUND(LOG(6, 3), 2); -- Output: 0.61

For LOG(B,X), X must be greater than 0 and the base B must be greater than 1.

SELECT LOG(6, -0.1); -- Output: NULL
SELECT LOG(-6, 2); -- Output: NULL
SELECT LOG(6, 0.1); -- Output: -1.28509720893847

Syntax

SELECT LOG(X);
SELECT LOG(B, X);



Subscribe to our YouTube Channel here



plus2net.com




SQL Video Tutorials










✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer