2015-10-20 93 views
1

我需要给条件MySQL查询里面,如果条件里面MySQL查询

select IF(r.name=NULL,'customer',r.name) as previlage 
from users u LEFT JOIN role r on r.rid = u.uid ORDER BY u.created DESC\G 

我需要检查if the r.name field is null then it should be displayed as customer,但现在if r.name is NULL then its displayed as null itself。我怎样才能做到这一点,谢谢。

回答