September 10th, 2000, 05:00 PM
I am using MySQL with PHP and when trying to divide a result in multiple pages of 10 results each, I asked myself something that I couldn't answer...
What is faster?
1) Two selects
SELECT id FROM table
SELECT * FROM table LIMIT 10
2) or one BIG select?
SELECT * FROM table
I need to get the toatl results so the script can display the correct number of pages.
Since it applies to searches too, the select may be big, like:
SELECT * FROM table WHERE keyword LIKE "%key1%" AND keyword LIKE "%key2%" AND keyword LIKE "%key3%" ...
So, what is the fastest solution?
Eduardo Teixeira Cardoso
PHP Programmer from Brazil