select * from Table where ID = 7 and Flag = 1 UNION select * from Table where ID = 7 WHERE NOT EXISTS (select * from Table where ID = 7 and Flag = 1)