Možda da pogledaš funkcije opisane ovde, posebno IF (a možda u kombinaciji sa još nekom kao IFNULL)
http://dev.mysql.com/doc/refman/5.0/...functions.html
IF(expr1,expr2,expr3)
If expr1 is TRUE (expr1 <> 0 and expr1 <> NULL) then IF() returns expr2; otherwise it returns expr3. IF() returns a numeric or string value, depending on the context in which it is used.