DQL IF или Ifnull
case when c.type_id = 9 then c.name else c.lastname end as name
Rich Raccoon
case when c.type_id = 9 then c.name else c.lastname end as name