From the course: MySQL Essential Training

Unlock this course with a free trial

Join today to access over 23,700 courses taught by industry experts.

Integer division

Integer division

- [Bill] Hi, I am Bill Weinman. The SQL standard uses functions to perform integer division and the modulo operation to provide the remainder of an integer division. MySQL uses non-standard operators for this. If we say SELECT, say 47 divided by three, we get a real number, 15.666 et cetera, and this is a real division operation. The result is a real number with the fractional part represented as digits after the decimal point, and this usage conforms to the standard. In the SQL standard, if you want to get an integer division of these numbers, you would use the DIV function and the operands would be parameters to the function like this, 47 comma three. But you'll notice I've got a little red X there and if I try to execute this, I get an error. It says down here, "You have an error in your SQL syntax" and to check the manual. So MySQL does not support the standard DIV function, instead, MySQL supports a DIV operator like this. And this is not standard SQL but this is how it works in…

Contents