Database API join fields i've got a database query with a join like this:

$query = db_select('node', 'n');
$query-&gt;condition('n.nid', 0, '&lt;&gt;')
  -&gt;fields('n')
  -&gt;range(0, 50);

$query-&gt;leftJoin('field_data_field_prospekt_owner','prospekt','prospekt.revision_id = n.nid');


Let's say I want to get the fields from my 'field_data_field_prospekt_owner' table in the result. How do I go about that?

i tried extending the fields function like query-&gt;fields('n,prospekt') but this throws an error.

query-&gt;fields('n')-&gt;fields('prospekt') isn't working, unfortunately. I'm getting a error:


  PDOException: SQLSTATE[42S02]: Base table or view not found: 1051 Unknown table 'prospekt': SELECT n., prospekt. FROM {node} n {} LEFT OUTER JOIN {field_data_field_prospekt_owner} prospekt_2 ON prospekt.revision_id = n.nid WHERE (n.nid &lt;> :db_condition_placeholder_0) LIMIT 50 OFFSET 0; Array ( [:db_condition_placeholder_0] => 0 ) in main() (Zeile 42 von /var/www/asvg/prospekt_iframe.php)
You should do

$query-&gt;fields('n')-&gt;fields('prospekt');


See the documentation for more info.

Note that querying field tables this way is not recommended as the tables are created dynamically. You should only fetch field data via APIs.