select t1.id,t3.name as project,t3.id,IF(t3.multiple="1",t1.name,"") as execution,t1.id as bugID,t2.openedBy from TABLE_EXECUTION as t1 
left join TABLE_BUG as t2 on t1.id=t2.execution
left join TABLE_PROJECT as t3 on t3.id=t1.project
where t1.deleted='0' and t2.deleted='0' having bugID!='' and if($project='',1,t3.id=$project) and if($execution='',1,t1.id=$execution)