Working with a checkbox and EntityFieldQuery So I have a custom field which is a checkbox and is called 'field_hide_panel'.

The on value is '1' and the off value is '0'. But bare in mind, this field was added later so there are a lot of rows in my database which will not have any field_hide_panel value. 

When this checkbox is selected it should be omitted from the results of my query. 

I have this line to try to achieve this:

$query-&gt;fieldCondition('field_hide_panel','value', '1', '!='); 


The problem is, I'm not getting anything returned. I think this is because most of my nodes don't have a 'field_hide_panel' value at all but I still want these returned as my logic says these should still show because field_hide_panel does not equal 1.

Is there any way around this without me having to go through hundreds of nodes and re-save them so they get '0' as the field_hide_panel?
You can add tag to your query and use hook_query_TAG_alter() to add additional conditions. Here's an example:

function mymodule_get_nodes() {
  $query = new EntityFieldQuery();
  $query-&gt;entityCondition('entity_type', 'node')
    -&gt;addTag('node_is_not_tagged');
  return $query-&gt;execute();
}

/**
 * Implements hook_query_TAG_alter().
 */
function mymodule_query_node_is_not_tagged_alter(QueryAlterableInterface $query) {
  $query-&gt;leftJoin('field_data_field_hide_panel', 'hp', 'node.nid = hp.entity_id AND hp.entity_type = :entity_type');
  $or = db_or()
    -&gt;condition('hp.field_hide_panel', 0)
    -&gt;isNull('hp.field_hide_panel');
  $query-&gt;condition($or);
}


Link to relative issue: https://www.drupal.org/node/1157006