How to use db_select and apply a condition for another table's data? I know this is probably the dumbest question ever but I'm just not getting warm with SQL.

I am writing this function which loads all users that have a role assigned:

function mymodule_get_users_by_role($rolename) {
  $role = user_role_load_by_name($rolename);
  $uids = db_select('users_roles', 'ur')
      -&gt;fields('ur', array('uid'))
      -&gt;condition('ur.rid', $role-&gt;rid, '=')
      // -&gt;leftJoin('users', 'us', '(us.uid = ur.uid AND us.status = 1)')
      -&gt;execute()
      -&gt;fetchCol();
  return user_load_multiple($uids);
}


But I only want those users which's status = 1. I could do it afterwards but I really hope there is a way within the QuerySelect to add this filter beforehands. The commented line just produces a white screen of death so I'ma go with a nope. I dont even know if leftJoin is the right thing to do.

Thanks!
The following query should be self-explanatory.

$query=db_select('table1','t1');
$query-&gt;join('table2','t2','t1.nid = t2.nid');

$query-&gt;condition('t1.uid','1')
      -&gt;condition('t2.uid','3')
      -&gt;fields('t1',array('uid','nid'))
      -&gt;fields('t2',array('date'));