Mysql method to convert negative numbers to positive numbers: use the function [abs();] to convert negative numbers to positive numbers, the code is [mysql> select abs(3-5);abs(3-5);row in set (0.00 sec)].
Mysql method to convert negative numbers to positive numbers:
1, MySQL
Function: abs ()
abs(); //Convert negative numbers to positive numbers
as follows:
mysql> select abs(3-5); +----------+ | abs(3-5) | +----------+ | 2 | +----------+ row in set (0.00 sec)
2, PHP
Function: abs()
<?php $test = -1; echo $test; $test = abs($test); echo $test;
Output:
-1
1
##More related free learning recommendations: mysql tutorial(Video)
The above is the detailed content of How to convert negative numbers to positive numbers in mysql. For more information, please follow other related articles on the PHP Chinese website!