Home > Database > Mysql Tutorial > How to convert negative numbers to positive numbers in mysql

How to convert negative numbers to positive numbers in mysql

coldplay.xixi
Release: 2020-10-29 16:14:41
Original
5479 people have browsed it

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)].

How to convert negative numbers to positive numbers in mysql

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)
Copy after login

2, PHP

Function: abs()

<?php
$test = -1;
echo $test;
$test = abs($test);
echo $test;
Copy after login

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!

Related labels:
source:php.cn
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