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

What is the use of MySQL TRUNCATE() function?

WBOY
WBOYforward
2023-08-30 19:33:11648browse

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)

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)

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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete