Hi all, 

I have a few questions about query structure.

1. COUNT(*) Is there anything wrong with using 
    SELECT COUNT(*) 
    FROM bleah 
or should I be using
    SELECT COUNT(someField)
    FROM bleah

2. Is two queries a lot less efficient than one?
Background: I have a table with about 20 fields of business 
Information. How much information needs to be displayed 
depends on what "packageID" the business has.
So, if I look at all the business is one category, I may get
20,000 records returned. However, only 10 of those may need
all twenty fields returned.
Currently I'm using one query, 
SELECT * 
FROM business 
WHERE categoryID='$categoryID'
LIMIT $pageStart, $pageEnd //this is to only return five records per page

But in one case, where I have to join two tables, the 
temporary table it creates is too big. Would it be a lot 
slower to say:
SELECT *
FROM business 
WHERE categoryID='$categoryID' && packageID='1' 
LIMIT $pageStart, $pageEnd
Display these results, using a counter to keep track of how many 
are returned (in case less than 5 are)
Then do another query
SELECT (here list the fields necessary)
FROM business
WHERE categoryID='$categoryID' && packageID='2'
LIMIT $counter+$pageStart, $pageEnd

Hope this makes sense.

Anna

Reply via email to