Custom Module: db_select title AND body? I'm a little confused by how the node data is stored in the database.  It seems like the title is stored in the db "node," while the body is stashed field_data_body, and custom fields are placed elsewhere.

I have create a custom module that pulls certain pieces of content, but I need to match up the title with the body.  I've been successful pulling my list of titles:

    function foo() {
      $query = db_select('node', 'n')
       -&gt;fields('n', array('type','title', 'nid'))
       -&gt;condition('type', 'fooBar')
       -&gt;condition('status',1)
       -&gt;execute();
          return $query;
      }
      $result=foo();
        foreach ($result as $node) {
         $id = $node-&gt;nid;
        }


How can I match each of these with their bodies?

Thanks!
-JB
If you want directly include the body within your result set, you can do a join on the field_data_body table.

$query = db_select('node', 'n');

$query-&gt;leftJoin('field_data_body', 'd', '(d.entity_id = n.nid AND d.entity_type = :node)', array(':node' =&gt; 'node'));

$query
    -&gt;fields('n', array('type', 'title', 'nid'))
    -&gt;fields('d', array('body_value', 'body_summary', 'body_format'))
    -&gt;condition('type', 'fooBar')
    -&gt;condition('status', 1)
    -&gt;execute();