If the absolute value of the difference between two values is greater than a certain number, we can use the MySQL absolute value i.e. ABS() function to select records from the table. We demonstrate this using data from the "Marks" table.
mysql> Select * from studentmarks where abs(Hindi-English)>10; +--------+-------+---------+------+---------+-----------+ | Name | Hindi | English | Math | Physics | Chemistry | +--------+-------+---------+------+---------+-----------+ | Gaurav | 75 | 86 | 95 | 69 | 85 | | Rahul | 74 | 85 | 97 | 69 | 86 | | Mohit | 73 | 87 | 89 | 69 | 86 | +--------+-------+---------+------+---------+-----------+ 3 rows in set (0.00 sec)
The above result set only contains records where the absolute value of the difference between the two subjects English and Hindi is greater than 10.
The above is the detailed content of How can we select records from a table if the absolute value of the difference between two values is greater than a certain number?. For more information, please follow other related articles on the PHP Chinese website!