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.

sql fiddle demo

select ff.*,         @rownum := @rownum + 1 rank   ff,         (select @rownum := 0) r name = 'beta'   order asort 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -