How do I add an OR expression between two ->addExpression() in Drupal 7
addExpression() is for adding expressions to the query, (i.e. fields that will be selected), you can't use it to add conditions.

You could either use a combination of db_and() and db_or() to build up your conditions, or (and probably easier) just use the where() method instead:

$condition = '(flag.fid is not null AND flag.fid = :fid1) OR (flag.fid is not null AND flag.fid = :fid2)';
$query-&gt;where($condition, array(':fid1' =&gt; 2, ':fid2' =&gt; 3);