I have two tables in my database: tb_authors and tb_posts.
I need to display a list of authors ordered by the number of posts each one has in descending order.
Both tables have in common an id_author
key.
Anyone can help me?
Ok, so far I got this:
SELECT tb_authors.*, COUNT(tb_posts.*) AS thecount FROM tb_posts, tb_authors WHERE tb_authors.id_author = tb_posts.id_author ORDER BY thecount DESC;
But it's not working. It returns 1 column with one Author and the thecount
has the value of total posts.