[snip]
I want to optimize one of my php scripts to acess mysql only once. Is there
anyway to put these two queries together:

SELECT COUNT(*) from TABLE where name="JOHN"
SELECT * from TABLE where name="JOHN" limit 10
[/snip]

try

select *,
sum(if(name = 'JOHN', 1, 0)) AS COUNT
from table
where name = 'JOHN'
group by name

HTH!

Jay



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to