Integer division in MySQL Integer division in MySQL mysql mysql

Integer division in MySQL


Use the DIV operator.

mysql> SELECT 5 DIV 2;    -> 2

Integer division. Similar to FLOOR(), but is safe with BIGINT values. Incorrect results may occur for noninteger operands that exceed BIGINT range.


SELECT *FROM productWHERE product_id BETWEEN 1103010000                     AND 1103019999  

If you want to create your query in PHP, then you can construct your query like

$sql = "    SELECT *    FROM product    WHERE product_id BETWEEN {$product_id_range}0000                         AND {$product_id_range}9999  ";


SELECT *   FROM `product`  WHERE `product_id` >= 1103010000    AND `product_id` <= 1103019999