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