Re: Re: Tag Cloud (WAS Deviation? Distribution? OT?)

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

 




On Thu, May 3, 2007 10:00 am, Stut wrote:
> Richard Lynch wrote:
>>   $query = "select tag, popular from (select tag, count(*) as
>> popular
>> from entry_tag group by tag order by popular desc limit 100) as p
>> order by tag";
>
> I'm no expert, and I have no way to test this, but the following
> should
> work and gets shot of the sub-select...
>
> select tag, count(1) as popular
> from entry_tag
> group by tag
> order by popular desc, tag
> limit 100

But the whole point is to order by tag in the end, not popular desc...

In the final output, the tags are in alpha order for easy scanning
across.

The popularity is rendered in larger/bolder/darker text for, errr,
that not-quite-focuesed-zoom-in-on-big-things look. :-)

The inner query sorts by popularity to get the "Top 100".

The outer query sorts that inner result alphabetized.

I don't *think* you can get that in a single non-join non-nexted
query, but I ain't no SQL expert either...

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux