Complex SelectQuery with multiple left joins and conditions with OR
It seems that the problem was $field-&gt;field. For example if I have a field called field_book_author in database the $field-&gt;table would be field_data_field_book_author and the value of the field would be in field_book_author_value.

So the correct code is:

$or = db_or();
foreach ($fields as $field) {
    $query-&gt;leftJoin($field-&gt;table, $field-&gt;table, '(node.nid = ' . $field-&gt;table . '.entity_id)');

    if (property_exists($field, 'additional_fields') &amp;&amp; (count($field-&gt;additional_fields) &gt; 3)) {
        $field_name = $field-&gt;additional_fields[3];
    }else {
        $field_name = $field-&gt;field;
    }
    $or-&gt;condition($field-&gt;table . '.' . $field_name, '%' . $string . '%', 'LIKE');
}

$query-&gt;condition($or);