Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wish I Could Do Subqueries... 1

Status
Not open for further replies.

cLFlaVA

Programmer
Jun 14, 2004
6,450
US
Hi all.

I have a table like this:

[tt]tag_id tag_name tag_entry_id
1 cory 9999
2 bob 9999
3 tim 9999
4 cara 8888
5 claire 8888
6 cory 8888
7 cara 7777
8 cory 6666[/tt]

i'm trying to get a list of the top-5 most popular tags, ordered alphabetically. obviously in this example there are only 5 distinct tags, but hopefully there's enough information for you to help me.

my Mysql version doesn't support subqueries.

Thanks!

Cory



*cLFlaVA
----------------------------
[tt]mr. pibb + red vines = crazy delicious![/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
You would have to use a temporary table:
[tt]
CREATE TEMPORARY TABLE t AS
SELECT tag_name,count(*) c
FROM tags
GROUP BY tag_name
ORDER BY c DESC
LIMIT 5;

SELECT tag_name FROM t ORDER BY tag_name;
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top