背景
返回的参数按照条件 如果字段为null值 则 返回0 状态,不为null则返回 1状态
思路
使用if实现SQL语句中的判断
解决方案
select ac.tuid,ac.limit_price,ac.task_name,dt.task_goal,dt.task_type,dg.good_num,dg.product_code,dg.good_type,(case when rt.entity_id is null then 0 else 2 end ) status,
IFNULL(finish_num,0) finish_num,IFNULL(is_finish,0) is_finish,IFNULL(is_receive,0) is_receive,s.product_code chest_code
from pm_activity_relation ac
inner join pm_dotask dt on ac.task_id=dt.dotask_id
inner join
(select dg.task_id,GROUP_CONCAT(s.product_code) product_code,GROUP_CONCAT(dg.good_num) good_num,GROUP_CONCAT(dg.good_type) good_type
from pm_dotask_goods dg inner join pm_shop s on dg.good_id=s.tuid group by dg.task_id)
dg on dt.dotask_id=dg.task_id
left join (select entity_id,finish_num,is_finish,is_receive from pm_role_finish_task where entity_type=#{entityType} and role_id=#{roleId} ) rt on ac.tuid=rt.entity_id
left join pm_shop s on ac.chest_id=s.tuid
where ac.activity_id=#{activityId}
解决问题
还有其他方法.