TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

MySQL

MySQL Arithmetic Operators

Overview

In this tutorial, we will learn about MySQL Arithmetic operators with examples.

MySQL Arithmetic Operators

Arithmetic operators are used to perform mathematical operations like addition, subtraction, etc on the column values. MySQL arithmetic operators are as follows:

 

MySQL Arithmetic Operator Description
+ Addition
– Subtraction
* Multiplication
/ Division
DIV Integer Division
% Modulo – Remainder after integer division

Operator Precedence

The arithmetic operators have the following precedence.

* multiplication, / Division, % Modulo
– Subtraction, + Addition

Multiplication , Division, Modulo have higher precedence over the Subtraction and Addition operators.

Examples

mysql> SELECT 7 + 9;
+——-+
| 7 + 9 |
+——-+
| 16 |
+——-+
1 row in set (0.02 sec)

MySQL Arithmetic Addition Operator

Modulus operator

mysql> SELECT 17 % 3;
+——–+
| 17 % 3 |
+——–+
| 2 |
+——–+
1 row in set (0.00 sec)

Returns the remainder after the integer division.

MySQL Modulus Operator

#

mysql> SELECT 2 * 3 + 7;
+———–+
| 2 * 3 + 7 |
+———–+
| 13 |
+———–+
1 row in set (0.00 sec)

mysql> — The * operator has high precedence over +
mysql> — 2 * 3 + 7 -> 6 + 7 -> 13
mysql> — result = 13
mysql> — If + had higher precedence then the result would
mysql> — have been 20! But, It’s NOT the case

MySQL Arithmetic Operator Precedence

—

MySQL Tutorials

MySQL Tutorials on this website:

https://www.testingdocs.com/mysql-tutorials-for-beginners/

For more information on MySQL Database:

https://www.mysql.com/

Related Posts

DataGrip Desktop Shortcut

MySQL /

Launch DataGrip on Windows

DataGrip Download

MySQL /

Install DataGrip IDE on Windows 11

MySQL Workbench Windows 11

MySQL /

New MySQL Connection in Workbench

MySQL Command-line Client

MySQL /

Command-Line MySQL Client

Start MySQL Client

MySQL /

Start MySQL Client on Windows 11

‹ MySQL SELECT WHERE Clause› MySQL Comparison Operators

Recent Posts

  • MS Access Data Types
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version