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