Re: Finding the 'page' number of a record, or its position in resultset

2006-10-18 Thread Gareth Adams
Jerry Schwartz the-infoshop.com> writes: > I'm still confused, are you saying that you want to know what page a team > would be on if you did a listing? > > Regards, Yes, given a query (e.g. "SELECT ... FROM teams ORDER BY score DESC, errors") which we usually add a LIMIT clause to for paginati

Re: Finding the 'page' number of a record, or its position in resultset

2006-10-18 Thread Gareth Adams
Jerry Schwartz the-infoshop.com> writes: > Can't you just keep track of which page you are on, and multiply by 20 > (except for the last page)? I must be missing something. > > Regards, Hi Jerry, The problem is that the page isn't necessarily known at the time we need to find out its position.

Finding the 'page' number of a record, or its position in resultset

2006-10-18 Thread Gareth Adams
Hi, We have an application which queries our database in 'pages', i.e. uses the same query repeatedly, with a different "LIMIT x, 20" to display blocks of 20 results. I'm wondering if there's an easy way (or any way) to find out where in the resultset a particular record lies. Obviously the quer

Limiting JOIN queries

2006-09-14 Thread Gareth Adams
I hope this is a simple question. I'm trying to run a select like the one below, but limiting the results to 2 Sub Categories per Category. I can't find a way to do this in the SQL reference mysql> select sub_categories.id, categories.name 'Category', sub_categories.name 'Sub Category' from cate