I have two tables: a category table and a main table. Each record in the
main table belongs to a category (through reference to a PRIMARY KEY in the
category table).
I want to do a SELECT and get back a list of categories ordered by the
number of records in the main table. In other words, I want to know the
order of popularity of the categories.
CATEGORY
--------
ID TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
name CHAR(20) NOT NULL
MAIN
----
ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
categoryID TINYINT UNSIGNED NOT NULL,
a_field CHAR(40) NOT NULL
SELECT CATEGORY.name FROM CATEGORY, MAIN WHERE MAIN.categoryID=CATEGORY.ID
ORDER BY ?????????
****************
Michael A. Smith | [EMAIL PROTECTED]
Site Development Engineer | digitalNATION | http://www.dn.net
****************
"The programmer, like the poet, works only slightly removed from pure
thought-stuff. He builds his castles in the air, from air, creating by
exertion of the imagination. Few media of creation are so flexible, so easy
to polish and rework, so readily capable of realizing grand conceptual
structures."
--Frederick P. Brooks, Jr
The Mythical Man-Month
****************
-----------------------------------------------------------
Send a mail to [EMAIL PROTECTED] with
unsubscribe mysql [EMAIL PROTECTED]
in the body of the message to unsubscribe from this list.