Excluding empty(Null) fields when using EntityFieldQuery query condition Is it possible to select all of the entities who's xyz field is empty?

I tried soemthing like this:

-&gt;fieldCondition('field_name', 'value', NULL, 'IS NOT NULL');


However, this doesn't seem to work.

Any ideas?
If you look on the fieldCondition documentation page you will see the following warning:


  Note that entities with empty field values will be excluded from the EntityFieldQuery results when using this method.


Checking whether a field exists or not has been added to entityFieldQuery in Drupal 8, but unfortunately won't be backported to Drupal 7.

There are various methods to achieve this:


Using a tag and hook_query_TAG_alter as mentioned by @Clive, see comment 4 on  the Drupal issue for an example ;
First query all non NULL entries, then query all entries excluding the previous ones, as described in @seddonym's answer and in comment 5 on the Drupal issue ;
You can write your query using SelectQuery rathen than EntityfieldQuery as such:


_

$q = db_select('node', 'n');
$q-&gt;fields('n', array('type'))
  -&gt;condition('n.type', 'my_node_type', '=')
  -&gt;addJoin('LEFT', 'field_data_field_my_field', 'f', 'f.entity_id = n.nid');
$q-&gt;isNull('f.value');
$r = $q-&gt;execute();