limit db_select query by the value of a specific field
Scott's answer and Triskelion's comment are both spot on, but there are also a couple of other solutions that are worth mentioning.


Query the database for some node IDs that match a condition, load them using node_load_multiple(), and inspect the field data:

$nids = db_select('node', 'n')
  -&gt;fields('n', array('nid'))
  -&gt;condition('status', 1)
  -&gt;condition('type', 'salesforce_contacts')
  -&gt;condition('n.title', 'Abouzeid')
  -&gt;orderBy('title', 'ASC')
  -&gt;execute();

$nodes = node_load_multiple($nids);

foreach ($nodes as $node) {
  $title = $node-&gt;title;
  $created = $node-&gt;created;
  // etc.

  if ($field_items = field_get_items('node', $node, 'field_account_id')) {
    $account_id = $field_items[0]['value'];
  }
}

Use an EntityFieldQuery to query the nodes. This method has the advantage of being able to add conditions based on fields, as well as just the columns available in the node table.

$query = new EntityFieldQuery();
$query-&gt;entityCondition('entity_type', 'node')
  -&gt;propertyCondition('type', 'salesforce_contacts')
  -&gt;propertyCondition('status', 1)
  -&gt;propertyCondition('title', 'Abouzeid')
  -&gt;propertyOrderBy('title')

$results = $query-&gt;execute();
if (!empty($results['node'])) {
  $nodes = node_load_multiple(array_keys($results['node']));

  // Loop through the nodes as in the above example.
}