I'm trying to do a left join but it isn't working.
I have 2 tables:
TABLE profile
- uid
- pid
TABLE field_data_field_naam
- entity_id
- field_naam_value
I want to select the field_naam_value
where uid
is equal to .. and pid
equal to entity_id
. My normal query looks like this:
SELECT fdfm.field_naam_value, pf.uid
FROM field_data_field_naam fdfm
LEFT JOIN profile pf
ON fdfm.entity_id=pf.pid
WHERE pf.uid = 4
When I execute this on my database it works. Then I have this:
$naam = db_select('field_data_field_naam', 'fdfm')
->fields('fdfm', array('field_naam_value'));
$naam->leftJoin('profile', 'pf', 'fdfm.entity_id = pf.pid');
$naam->condition('uid', 4)
->execute();
And when I do the following:
foreach ($naam as $record) {
die;
}
nothing happens... (he doesn't kill the app). Also tried to add ->fetchAll()
but no success.