DATA-MANAGEMENT-FOUNDATIONS practice question 5 of 15

Which action does the % operator accomplish in MySQL?

Full set: 60 questions

Domain Data Querying

Answer options
A: Raises a numeric value to the power of another
B: Compares two numeric values for equality
C: Divides two numeric values and returns the remainder Correct answer
D: Subtracts a numeric value from another
Correct Answer:
C. Divides two numeric values and returns the remainder
Explanation

In MySQL, the % operator is the modulo operator. It is an arithmetic operator used to perform a division operation between two numeric values and return the integer remainder. For example, the expression 10 % 3 would evaluate to 1, because 10 divided by 3 is 3 with a remainder of 1. This operator is synonymous with the MOD() function in MySQL.

Why Incorrect

A. Raising a numeric value to the power of another is accomplished using the POW() or POWER() function in MySQL.
B. Comparing two numeric values for equality is performed using the equals (=) comparison operator.
D. Subtracting a numeric value from another is performed using the minus (-) arithmetic operator.

References

1. MySQL 8.0 Reference Manual: In the section on operators, it explicitly defines the % operator.

Source: MySQL 8.0 Reference Manual, Section 12.7, "Arithmetic Operators".

Quote/Paraphrase: The manual states, "% ... Modulo operator. Returns the remainder of N divided by M. It is synonymous with MOD(N,M)."

2. University of Michigan Courseware: Course materials for database design cover standard SQL operators, including the modulo operator.

Source: University of Michigan, School of Information, SI 664: Database Application Design, "SQL Arithmetic and Functions".

Quote/Paraphrase: The documentation lists arithmetic operators available in SQL, specifying that % (Modulo) calculates the "remainder of division."

Scroll to Top