var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: How do I display Results 18-29 of 1,680 ?
WHERE name > '$start'
ORDER BY name
1. I need to know the number of rows in the whole table. Can this be done without another query? COUNT(*) will give me just the rows returned from the above query...
2. I need to know where in set I am, based on what the value of $start is.
Looking to display: "Results 18-29 of 1,680"
not knowing mySQL that well, the only way I see is to read the whole table and process the results in a program.
I'm thinking there has to be a better/faster way!
Thanks for your help.
You'll need another query.
If you're using MyISAM, the overhead for a count(*) is insignificant as the count is stored as meta data.
If you're using InnoDB, then you might want to maintain your own counter table to avoid the required full index scan.
Thank you for your reply.
I'm using MyISAM...
Your answer helps with the overall count, but not the "where am I in the results" question...
Try using PHP:
$query1 = mysql_query("SELECT * FROM table LIMIT 17,28");
$rows = mysql_num_rows($query1);
Would return 12 rows displaying every field from 18 - 29.
$query2 = mysql_query("SELECT * FROM table");
$rows = mysql_num_rows($query2);
Would return as many rows as you have in the table.
I can run this on a table with over 30,000+ records and it returns very fast.
Last edited by progress; 02-06-03 at 00:20.