Click to See Complete Forum and Search --> : select a subset of rows from league table - help!


cooleofooleo
07-07-2007, 07:35 AM
I have a league with 15 teams, but I only want to show 5 teams at a time. However, one of these teams must be my team (TeamX).
So I need a select statement that will find TeamX and will return 5 teams with 3 teams above and 1 below it.
However, if TeamX is within the top 3, I just need to display the top 5 teams, and if TeamX is bottom of the league, I just need to display the 4 teams above it!

I have absolutely no idea how to go about doing this! Im using a mySQL database, developing an asp.net website with c#.net. (Sorry Microsoft - but cant afford SQL Server!)

mwiseley
07-07-2007, 04:59 PM
What are you sorting the results by?

You might start by looking at the documentation for the "limit" keyword supported by MySQL.

cooleofooleo
07-08-2007, 05:40 AM
Im sorting by Points.
TeamID, TeamName, Played, Points.

I thought with limit you can only return the n number of rows from the top, or the bottom. I'll check out Limit in further detail.

barantamer
07-18-2007, 07:37 PM
well , this is actually a php question , you can select teams and order them by points , and while fetching you can use a counter to now where is your team exactly.. Then use a switch statement and thats it....

bubbisthedog
07-19-2007, 09:50 AM
well , this is actually a php question , you can select teams and order them by points , and while fetching you can use a counter to now where is your team exactly.. Then use a switch statement and thats it....
FYI: They're using C#.