i've got a database query with a join like this:
$query = db_select('node', 'n');
$query->condition('n.nid', 0, '<>')
->fields('n')
->range(0, 50);
$query->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->fields('n,prospekt')
but this throws an error.
query->fields('n')->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 <> :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)
query->fields('n')->fields('prospekt');
is working fine, the problem is thatprospect
table alias does not exists. Provide full code.