2015-10-20 130 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。我怎樣才能做到這一點,謝謝。

回答