The simply the best collection of JOIN scripts
How to join results from one MySQL table while counting matching records in another table and sorting the result according to the count of the 2nd table using PHP.