mysql if示例

1 SELECT IF(ed.id IS NULL, '0', ed.id) id, IF(ed.name IS NULL, '其他', ed.name) name, COUNT(up.uid) memberCount, IF(ed.create_time IS NULL, NOW(), ed.create_time) create_time FROM user_profile up 
2             LEFT JOIN enterprise_departments_users edu ON up.uid = edu.uid 
3             LEFT JOIN enterprise_department ed ON edu.department_id = ed.id 
4             WHERE up.enterprise_id = ? GROUP BY ed.top_id, ed.create_time ORDER BY ed.create_time ASC;

 

posted @ 2016-04-29 10:14  下一个雨季~  阅读(160)  评论(0编辑  收藏  举报