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 OperatorDescription
+Addition
–Subtraction
*Multiplication
/Division
DIVInteger 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

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

Windows 11 Services Run Prompt

MySQL /

Start MySQL Server on Windows 11

MySQL Download Windows 11

MySQL /

Download & Install MySQL on Windows 11

‹ MySQL SELECT WHERE Clause› MySQL Comparison Operators

Recent Posts

  • Flowchart Control structures
  • Flowgorithm Layout Windows
  • Draw a Square using Turtle Graphics
  • Flowgorithm File Errors
  • Write to Text File using Flowgorithm
  • Read Text File using Flowgorithm
  • Flowgorithm Turtle Graphics Flowchart
  • Update Flowgorithm to Latest Version
  • Flowgorithm File Symbols
  • Flowgorithm Turtle Graphics

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version