Joins and looking for NULL values
The database API actually has a preferred way to add expressions of this type, namely the SelectQuery::isNull() and SelectQuery::isNotNull() functions. You can use them like this:

$query-&gt;isNull('f.fid');

$query-&gt;isNotNull('q.field_question_value');