php - Mysql return the row position with sorting -
the ff table:
+-----------------------------+ + value| name |asort + +-----------------------------+ + 111 | alpha |a + + 161 | beta |b + + 092 | delta |c + + 141 | beta |a + + 113 | beta |e + + 092 | delta |f + + ... + + ... | more items + +-----------------------------+ +-----------------------------+ + value| name |asort + +-----------------------------+ + 141 | beta |a + + 161 | beta |b + + 113 | beta |c + + ... + + ... | more items(beta) + +-----------------------------+
i want return of "3" "113" row position group name beta , sort asc asort
you need use variable calculate rank (row-number-in-mysql) because mysql doesnt have row_number
.
select ff.*, @rownum := @rownum + 1 rank ff, (select @rownum := 0) r name = 'beta' order asort
Comments
Post a Comment