division - Do a SELECT in MYSQL to return the remainder of an ID COUNT/8 -


i know how query in mysql remainder of id_count / 8.

here's example table:

 id (int)  | product id | time   1        |     14     | 09:34:00   5        |     26     | 09:47:00   5        |     01     | 09:58:00   1        |     02     | 10:10:00   2        |     63     | 10:36:00   4        |     59     | 10:47:00   3        |     18     | 11:00:00   1        |     27     | 11:15:00   5        |     36     | 11:38:00   1        |     44     | 09:34:00   5        |     55     | 09:47:00   5        |     14     | 09:58:00   1        |     24     | 10:10:00   2        |     54     | 10:36:00   4        |     44     | 10:47:00   3        |     54     | 11:00:00   1        |     64     | 11:15:00   5        |     14     | 11:38:00 

what here is, every time new row inserted, want count of id (for example id=5 6), , them divide number 8 (6/8) , remainder of division.

i'm using php way, if there's no way of doing mysql.

thanks in advance, question fell free ask! miguel.

use mod function

query example

select count(1) mod 8 result `table` id=5 

query common example

select id, count(1) mod 8 result `table` group id 

Comments