Re: Combining 2 queries into 1?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



How about

select count(*) from online

Jon

On May 30, 2004, at 1:23 PM, Kim Steinhaug wrote:

I have theese two queries :

select count(*) as online from online where uid='';
select count(*) as online from online where uid!='';

Each online user has a uid (UserID), so if their logged
inn this field will represent their unique uid. If not logged
in its set to nothing.

To detect how many online users the first query tells me
all the "anonymous" users and the second gives "members".

Since theese two queries are fired on every page hit, I would
assume that if I could join theese queries into one I would
atleast save the mysql for a 50% of the queries.

Ive veeb experimenting on the count(expression) without
any luck, probably since the server is running v4.0.17-standard

So I wonder - is there any way I could join the above queries
into one single query? Ofcourse I could easily add another
field for the database, something like temp which is NULL for
anonymous and 1 for user if this makes is easier to group the
the query in some wmart way I havnt figured out at the moment.

--
--
Kim Steinhaug
----------------------------------------------------------------------
There are 10 types of people when it comes to binary numbers:
those who understand them, and those who don't.
----------------------------------------------------------------------
www.steinhaug.com - www.easywebshop.no - www.webkitpro.com
----------------------------------------------------------------------

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux