PHP – My SQL : abs() – numeric function
Problem Statement :
In this article, we are going to perform database operation with abs() operation using php.
So we are considering temperature database .
PHP stands for hyper text preprocessor, it also communicates with mysql database through xampp server.
MySQL is an query language that is used to manage the databases.
abs() is used to return the positive value in a table.
abs(23) = 23
Consider the table:
Convert the temperature column to positive.
SELECT city,ABS(temperature) FROM temperature;
city id : 1 — temperature : 15
city id : 2 — temperature : 455
city id : 3 — temperature : 55
- Start xampp server
- Create a database named database and create table named temperature.
- Write php code to insert records into the table.
- PHP code to perform abs() function by converting temperature negative to positive values
Attention reader! Don’t stop learning now. Learn SQL for interviews using SQL Course by GeeksforGeeks.