Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Go Programs
    • Python Programs
    • Java Programs

MySQL MOD Function

by suresh

MySQL MOD function is one of the SQL Mathematical Function, which is helpful to find the Modulus. Or say, MySQL MOD function finds the remainder of different values. The syntax of the MOD in MySQL is as shown below:

SELECT MOD(X, Y);

SELECT X % Y;

SELECT X MOD Y;

This MOD function divides the X with Y value and retunes the reminder.

MySQL MOD Function Example 1

The MOD function returns the remainder or Modulus of the given value. The following query shows multiple ways to use the MOD function.

SELECT MOD(25, 5);

SELECT MOD(25, 4), MOD(29, 9);

SELECT 29 MOD 9, 28 MOD 5, 29 % 5;
MySQL MOD Function 1

MySQL MOD Example 2

The MOD Mathematical Function also allows you to find Modulus of a column data. In this MySQL example, we are going to find the Modulus of Yearly Income column divided by 9.

SELECT EmpID, 
FirstName,
      LastName,
      Occupation,
      YearlyIncome,
      MOD(YearlyIncome, 9) AS Mod9Income,
      Sales,
      Sales MOD 5 AS Mod5Sales
FROM `MySQL Tutorial`.customer;
MySQL MOD Function 2

Placed Under: MySQL

  • How to Download MySQL
  • Install MySQL on Windows
  • MySQL Create Database
  • MySQL Delete Database
  • MySQL Create Table
  • MySQL Drop Table
  • MySQL SELECT Statement
  • MySQL ALIAS Column
  • MySQL Distinct
  • MySQL Insert Statement
  • MySQL Delete
  • MySQL Truncate Table
  • MySQL WHERE Clause
  • MySQL Order By
  • MySQL Group By
  • MySQL Having Clause
  • MySQL LIMIT
  • MySQL Arithmetic Operators
  • MySQL COALESCE Function
  • MySQL AND Operator
  • MySQL NOT Operator
  • MySQL OR Operator
  • MySQL XOR Operator
  • MySQL BETWEEN Operator
  • MySQL Not Between Operator
  • MySQL GREATEST Function
  • MYSQL LEAST Function
  • MySQL LIKE Operator
  • MySQL NOT LIKE Operator
  • MySQL IFNULL Operator
  • MySQL NULLIF Operator
  • MySQL INTERVAL Operator
  • MySQL IS Operator
  • MySQL IN Operator
  • MySQL NOT IN Operator
  • MySQL IS NOT NULL
  • MySQL IS NULL
  • MySQL Inner Join
  • MySQL Cross Join
  • MySQL Right Join
  • MySQL Left Join
  • MySQL Aggregate Functions
  • MySQL Date Functions
  • MySQL Date Function
  • MySQL String Functions
  • MySQL Numeric Functions

Copyright © 2021· All Rights Reserved.
About | Contact | Privacy Policy