问题:假如说这个条件有一条数据不满足,那么那条数据就不会读出来,,那么,我怎么才能把它读出并且赋值为空呢
方法:
1 SELECT 2 `s`.*, ( 3 CASE 4 WHEN `a`.`status` > 1 THEN 5 SUM(a.total_number) 6 WHEN `a`.`status` <= 1 THEN 7 NULL 8 END 9 ) AS sales 10 FROM 11 `ce_order` `a` 12 INNER JOIN ( 13 SELECT 14 `s`.*, b.company_name AS bloc_name 15 FROM 16 `ce_store` `s` 17 INNER JOIN `ce_bloc` `b` ON `s`.`bid` = `b`.`id` 18 ) s ON `a`.`uid` = `s`.`id` 19 GROUP BY 20 s.id
直接拷贝CASE 那段到控制器里就可以了
结果: