Find role based on list of permissions
Something like this should do it:

  $permissions = array('administer content', 'access content');
  $query = db_select('role', 'r')
    -&gt;fields('r', array('name'));
  $alias = 'rp';
  foreach($permissions as $perm){
    $query-&gt;innerJoin('role_permission', $alias, 'r.rid='.$alias.'.rid');
    $query-&gt;condition($alias.'.permission', $perm);
    $alias = $alias . 'a';
  }
  $result = $query-&gt;execute()-&gt;fetchAllAssoc('name');


It's doing separate inner joins with the role_permission table for each permission, to ensure that the role has all the permissions.