SitePoint Sponsor |
|
User Tag List
Results 1 to 2 of 2
Hybrid View
-
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"
$total_matches=mysql_num_rows;
Second Query: "SELECT * FROM Table_Name LIMIT 20"
etc...
Is this bad? Should I be trying to do this with just one MySQL query? Thanks!
-
Feb 6, 2001, 11:48 #2
- Join Date
- Apr 2000
- Posts
- 1,483
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I wouldn't worry about it - I can't think of a way to do what you need with one query on MySQL.
It shouldn't affect performance a lot
Bookmarks