I have two tables
Table users
user_id
user_name
Table comments
comment_id
comment_text
user_id
I want to get all country and number of films made in the country.
Currently i am doing
$data = array();
$result = mysql_query('select * from users');
while($users = mysql_fetch_assoc($result)) {
$user_id = $users['user_id'];
$result2 = mysql_query('select count(*) as total from comments where user_id = $user_id");
$comment = mysql_fetch_assoc($result2);
$data[] = array('id' => $users['user_id'], 'username' => $users['user_name'], 'total_comments' => $comment['total']);
}
Can i get this done in one sql ?