Home > Database > Mysql Tutorial > What is the use of MySQL TRUNCATE() function?

What is the use of MySQL TRUNCATE() function?

WBOY
Release: 2023-08-30 19:33:11
forward
697 people have browsed it

MySQL TRUNCATE() 函数有什么用?

MySQL TRUNCATE() The function returns the value of X truncated to D decimal places. If D is 0, remove the decimal point. If D is negative, the integer part of the D values ​​is truncated. The syntax is as follows -

Syntax

TRUNCATE(X, D)
Copy after login

Here

  • X is the number to be truncated.
  • D is the number after the decimal point. Number X must be truncated.

Example

In the example below, it will truncate the given number to up to 2 decimal places.

mysql> Select TRUNCATE(10.7336432,2);
+-----------------------+
| TRUNCATE(10.736432,2) |
+-----------------------+
|                 10.73 |
+-----------------------+
1 row in set (0.00 sec)
Copy after login

The above is the detailed content of What is the use of MySQL TRUNCATE() function?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template