Results 1 to 2 of 2
Feb 6, 2001, 09:45 #1
Sorry for the esoteric subject line, but I couldn't think of anything better. I'm using PHP to search a MySQL database, and I want to limit the number of matches displayed to 20 per page. But I also want to know the total number of matches. This kind of thing is seen all over the place, and I know how to do it with two separate SQL queries to the database. But is there a way to do it with a single query? Or should I not worry about this as a performance issue?
For example (and I'm being very loose here):
First Query: "SELECT Count(*) FROM Table_Name"
Second Query: "SELECT * FROM Table_Name LIMIT 20"
Is this bad? Should I be trying to do this with just one MySQL query? Thanks!