entityQuery filter by content moderation state
You try the code :

$query = \Drupal::database()-&gt;select('content_moderation_state_field_data', 'ms');
    $query-&gt;join('node_field_revision', 'nf', 'nf.nid=ms.content_entity_id AND nf.vid=ms.content_entity_revision_id AND nf.langcode=ms.langcode');
    $query-&gt;fields('ms');
    $query-&gt;condition('ms.moderation_state','draft');
    $results = $query-&gt;execute()-&gt;fetchAllAssoc('content_entity_id');


Because entityQuery not filter content moderation