Forums: Display Row Line Number (Master Or Detail Lists) - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Display Row Line Number (Master Or Detail Lists) simply MySQL trick to displaying a sequential row number

#1 User is offline   FunkDaddy 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 171
  • Joined: 17-March 10

Posted 28 January 2013 - 12:51 AM

I have a Master form which displays multiple child items. I wanted to show "line numbers" for each of the child rows. Ex:1,2,3,4,5 etc

I found a nifty solution which worked well for me here: Jims Life Blog

Oh, and by the way... even my updateable table queries could remain updateable even after I added this extra select code to MySQL statement in PHPR!

Just to be safe I am including the basic text here in case his blog goes down:

COPY &PASTED TEXT:
========================================================
Sometimes you need to do query with MySQL for reporting.
And you値l need to display the row number/ranking in query result.

Example you have this table:

table : player
fields : playerid, name & score

For reporting purpose you need to query the top 10 (highest score).
The result should be : rank, memberid, name, score.
Example :
rank playerid name score
覧覧覧覧覧蘭
1 A1029 Jimmy 100
2 A9830 Lia 98
3 B28d0 Lulu 90


10 B8789 Lele 50

Now you can easily query the top 10 by using 鼠imit and 双rder by, but how to automatically add row number in query result?

Here痴 how you do it:

select @rownum:=@rownum+1 喪ank, p.* from player p, (SELECT @rownum:=0) r order by score desc limit 10;

Try it

This will create a variable rownum, initialize with value 0 & increase it by 1 for every record

=============================================

Cheers,
Marcelo Ramagem

- Don't second guess your customer, instead listen, iterate, and deliver!
0

#2 User is offline   NikolaK 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 05-July 12

Posted 15 March 2019 - 09:34 AM

Can you tel me how to show row numbers in PHPrunner version 9.8, but on report page ?
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users