Convert db_query in EntityFieldQuery I have the following query, which works.

  $email = db_query('
    Select u.init as email 
    FROM user__roles as r 
    JOIN users_field_data as u ON r.entity_id = u.uid 
    WHERE u.status = 1 
      AND r.roles_target_id = :role
  ', array('role' =&gt; 'pubblisher'))-&gt;fetchAll();


I want to convert it to use EntityFieldQuery, but I didn't find any Join function in the documentation. How do I convert my code to use EntityFieldQuery?
As long as you only query for fields, entity query does the joins automatically for you.

Note that entity query can only return entity ID's, you then need to load them.

$ids = \Drupal::entityQuery('user')
  -&gt;condition('status', 1)
  -&gt;condition('roles', 'pubblisher')
  -&gt;execute();

$users = User::loadMultiple($ids);