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

From: Date: Thu, 03 May 2007 15:48:36 +0000
Subject: Re: Re: Tag Cloud (WAS Deviation? Distribution? OT?)
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-254343@lists.php.net to get a copy of this message
Richard Lynch wrote:
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...
Ahh, right, with you. Indeed, I can't see a way to do that either. Ignore me, go about your business. -Stut

« previous php.general (#254343) next »