Selecting data from 2 MySQL tables and sorting
Posted: Thu Jul 15, 2004 4:29 pm
I have 2 tables: the first one contains texts, the other one comments for the texts.
Like this:
1st table
2nd table
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?
Like this:
1st table
Code: Select all
+----+-----------------------------------------------------+
| id | text |
+----+-----------------------------------------------------+
| 1 | Some text here |
| 2 | Some more text here |
+----+-----------------------------------------------------+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 |
+----+--------+---------------------------+Can anybody help me please?