QUOTE(alex1985 @ Jul 31 2008, 06:03 AM)

Just show me the instance of it!
Ok, assuming that your news articles are represented as filenames, suppose that you have the following table:
CODE
CREATE TABLE news (
`ID` INT(3) NOT NULL AUTO_INCREMENT,
`FILENAME` VARCHAR(128) NOT NULL,
`CATEGORY` VARCHAR(32) NOT NULL DEFAULT 'misc',
`SUBCATEGORY` VARCHAR(32) NOT NULL DEFAULT '',
PRIMARY KEY (`ID`),
KEY INDEX_CATEGORY (CATEGORY),
KEY INDEX_SUBCATEGORY (SUBCATEGORY)
);
This will give you the following table:
CODE
+-------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+----------------+
| ID | int(3) | | PRI | NULL | auto_increment |
| FILENAME | varchar(128) | | | | |
| CATEGORY | varchar(32) | | MUL | misc | |
| SUBCATEGORY | varchar(32) | | MUL | | |
+-------------+--------------+------+-----+---------+----------------+
Now, let's insert some dummy records:
CODE
INSERT INTO news (FILENAME, CATEGORY, SUBCATEGORY) VALUES
("hp01.php", "Books", "Harry Potter"),
("hp02.php", "Books", "Harry Potter"),
("hp03.php", "Books", "Harry Potter"),
("kl01.php", "Books", "tlhIngan Hol"),
("nz01.php", "Politics", "Adolf Hitler"),
("nz02.php", "Politics", "Adolf Hitler"),
("as01.php", "Politics", "Arnold Schwarzenegger"),
("as02.php", "Politics", "Arnold Schwarzenegger"),
("es01.php", "Genius", "Albert Einstein"),
("ph01.php", "Genius", "Paris Hilton");
As you can see, we have three categories: Books (4),Politics (4) and Genius (4)
Books has two subcategories: Harry Potter (3) and tlhIngan Hol (1)
Politics has two subcategories: Adolf Hitler (2) and Arnold Schwarzenegger (2)
Genius, too, has two subcategories: Albert Einstein (1) and Paris Hilton (1)
Now, to get how many news articles you have under the category Books, use the following statement:
CODE
mysql> SELECT count(1) FROM news WHERE CATEGORY = "Books";
+----------+
| count(1) |
+----------+
| 4 |
+----------+
On the other hand, to see how many articles you have under the subcategory Paris Hilton, use the following statement:
CODE
SELECT count(1) FROM news WHERE SUBCATEGORY = "Paris Hilton";
+----------+
| count(1) |
+----------+
| 1 |
+----------+
Well, there you go. If you need any more information, it certainly wouldn't hurt to ask in a polite manner, be patient and non-aggressive. It definitely pays to be nice to people you're asking help from. Most of all, a lot of us developers here took the time to learn PHP and MySQL, which is why we know these things. You certainly cannot learn simply by bullying other people to give you the information that you want, when you can just as easily search online resources.
Ah, but I'm going off-topic. In any case, have a nice day
Reply