Page 1 of 1

Selecting data from 2 MySQL tables and sorting

Posted: Thu Jul 15, 2004 4:29 pm
by h@mm3r
I have 2 tables: the first one contains texts, the other one comments for the texts.
Like this:

1st table

Code: Select all

+----+-----------------------------------------------------+
| id | text                                                |
+----+-----------------------------------------------------+
|  1 | Some text here                                      |
|  2 | Some more text here                                 |
+----+-----------------------------------------------------+
2nd table

Code: Select all

+----+--------+---------------------------+
| id | textID | text                      |
+----+--------+---------------------------+
|  1 |      1 | This is a comment         |
|  2 |      1 | This is a comment         |
|  3 |      2 | This is a comment         |
|  4 |      2 | This is a comment         |
|  5 |      1 | This is a comment         |
|  6 |      2 | This is a comment         |
|  7 |      1 | This is a comment         |
|  8 |      2 | This is a comment         |
+----+--------+---------------------------+
Now, I want to list the texts ordered by the number of comments for each text. I think it has something to do with using multiple/selecting tables...
Can anybody help me please? :P

Posted: Thu Jul 15, 2004 4:39 pm
by feyd
viewtopic.php?t=23862

add an ORDER BY to my last post in that thread.

Posted: Thu Jul 15, 2004 5:08 pm
by h@mm3r
Thanks, that helped!