现要查询计划表信息,和组织权限相关联,目前sql
T_TRAIN_PLAN 表结构
t_employee_organization_ref表结构
select *
from (select distinct t.plan_name,
t.plan_code,
t.begin_date,
t.end_date,
t.id,
t.status,
t.verify,
t.isDel,
ROWNUM RN
from (select t.plan_name,
t.plan_code,
t.begin_date,
t.end_date,
t.id,
t.status,
t.verify,
row_number() over(order by create_time desc) as seqnum,
(select count(1)
from t_train_session ts
where ts.plan_id = t.id
and ts.train_begin_time < sysdate) isDel
FROM (SELECT *
FROM (SELECT t.store_id,
t.plan_name,
t.plan_code,
t.begin_date,
t.end_date,
t.id,
t.status,
t.verify,
create_time,
t.remark mark
FROM T_TRAIN_PLAN t
where t.status in ('0', '2') and t.remark is not null ) t,
t_employee_organization_ref a
where t.store_id = a.unit_id
and a.employee_code = 'admin') t) t
where seqnum <=10
order by t.begin_date desc)
where rn > 0;
抽取主体也就是
SELECT *
FROM (SELECT t.store_id,
t.plan_name,
t.plan_code,
t.begin_date,
t.end_date,
t.id,
t.status,
t.verify,
create_time,
t.remark mark
FROM T_TRAIN_PLAN t
where t.status in ('0', '2') and t.remark is not null ) t,
t_employee_organization_ref a
where t.store_id = a.unit_id
and a.employee_code = 'admin'
目前的业务是,当创建计划时,Store_id可以选择多个, 保存的时候,如果store_id是多个,则保存在了remark字段中,如果只是一个保存在store_id字段中, 那么问题
来了,如果store_id是多个,已逗号分隔的形式保存在了remark字段中,我怎么和t_employee_organization_ref 组织权限表关联啊? 并且查找出计划信息。。。