Trying to list all articles where category field is empty I have drupal 7 site and I'm trying to listing all articles (with title) and where category field is empty (taxonomy). I'm running this code in my page with ->isNull and without, but not any results. Can someone explain what I'm doing wrong in here and why this is not working?    

$query = db_select('node', 'n')
  -&gt;fields('n', array('nid'))
  -&gt;condition('n.type', 'article') 
  -&gt;condition('n.status', 1)
  -&gt;isNull('n.field_tags')
  -&gt;range(0, 10);

  $results = $query-&gt;execute();


I'm get this error all the time:


  PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column
  'n.field_tags' in 'where clause': SELECT n.nid AS nid FROM {node} n
  WHERE (n.type = :db_condition_placeholder_0) AND (n.status =
  :db_condition_placeholder_1) AND (n.field_tags IS NULL ) LIMIT 10
  OFFSET 0; Array ( [:db_condition_placeholder_0] => article
  [:db_condition_placeholder_1] => 1 ) in eval() (line 17 of
  /sites/site.com/modules/php/php.module(80) : eval()'d code).
It seems to me your mistake is you are requesting the column field_tags from the table node, which is not a column from node, so doesn't exist.
Unless you have a very specific database structure, your "field_tags" should be contained in the table field_data_field_tags, so you may have to make an INNER JOIN between these tables in your query (maybe using field_data_field_tags.entity_id = n.id), and then check if the n.id exists in field_data_field_tags.entity_id, or (maybe better) use a LEFT JOIN between field_data_field_tags and node, so only the node with a n.id existing in field_data_field_tags will be returned.