为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。
【DM版本】:
【问题描述】:select c.,
(select (CASE COUNT(a.id) WHEN 0 THEN false ELSE true END) as flag from project_activity_entry a
where a.activity_id=c.id and a.deleted=0 and a.user_id=1 order by a.create_time desc limit 1
) as flag
from project_activity c
where c.deleted=0 and c.id=1805791272344064002;查询时报引用列未找到
先测试下下面这个写法是否报错
select c.*
,case when exists(select 1
from project_activity_entry a
where activity_id=c.id
and a.deleted=0
and a.user_id=1
and a.id is not null
)
then 1 else 0
end as flag
from project_activity c
where c.deleted=0
and c.id=1805791272344064002;
两张表的创建语句发下看看
表结构发下