Jump to content

Finding and saving the position of a record in a sorted table


sunshinemike

Recommended Posts

Hi

 

I have a problem that must be easy to sort out.

 

I have a simple database storing sports teams results.

 

At the end of each month I sort the table and display the teams in order of 'points scored'

 

I want to be able to show if a team has gone up or down in the league table

 

 

eg

 

Team 1    101 points    -  (were in first place last month)

Team 2      99 points    +1 (were in 3rd place last month)

Team 3      85 Points    -1 (were in 2nd place last month)

Team 4      80 Points    +3 (were in 7th place last month)

 

 

I have added two new fields to my table called 'position' and 'last_position'

 

I wish to sort my table and replace the contents of the field 'position' with the current league placing so I can calculate the changes in positions from the previous month.

 

So , when I have a sorted table how can I record (in a field) the position of the record in the sorted table?

 

In days gone by when I used Dbase 3 I could simply use the function recno() (the record number in the sorted table). Is there a similar function in MySql ????

 

Many thanks

 

Mike

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.