怎样把这两条sql拼接在一起,就是既要第一条sql查询出来的数据,又要第二条查询出来的数据
--1查询受众目标全为空的select*fromt_coursetcwheretc.course_codenotin(selectct.course_codefromt_...
--1 查询受众目标全为空的
select*from t_course tc where tc.course_code not in ( select ct.course_code from t_course_target ct left join t_course tc on tc.course_code=ct.course_code)
--2 查询出类型、类别、处、部门已选择的
select * from t_course tc left join t_course_target ct on
tc.course_code=ct.course_code left join t_employee_organization_ref eor on ct.store_no=eor.unit_id
left join t_employee e on e.employee_code=eor.employee_code left join t_training_wishes tw on
tw.employee_code=e.employee_code and tw.course_id=tc.id where lower(e.employee_code)=lower('E00113885') 展开
select*from t_course tc where tc.course_code not in ( select ct.course_code from t_course_target ct left join t_course tc on tc.course_code=ct.course_code)
--2 查询出类型、类别、处、部门已选择的
select * from t_course tc left join t_course_target ct on
tc.course_code=ct.course_code left join t_employee_organization_ref eor on ct.store_no=eor.unit_id
left join t_employee e on e.employee_code=eor.employee_code left join t_training_wishes tw on
tw.employee_code=e.employee_code and tw.course_id=tc.id where lower(e.employee_code)=lower('E00113885') 展开
2个回答
展开全部
select*from t_course tc where tc.course_code not in ( select ct.course_code from t_course_target ct left join t_course tc on tc.course_code=ct.course_code)
union all
select * from t_course tc left join t_course_target ct on
tc.course_code=ct.course_code left join t_employee_organization_ref eor on ct.store_no=eor.unit_id
left join t_employee e on e.employee_code=eor.employee_code left join t_training_wishes tw on
tw.employee_code=e.employee_code and tw.course_id=tc.id where lower(e.employee_code)=lower('E00113885')
union all
select * from t_course tc left join t_course_target ct on
tc.course_code=ct.course_code left join t_employee_organization_ref eor on ct.store_no=eor.unit_id
left join t_employee e on e.employee_code=eor.employee_code left join t_training_wishes tw on
tw.employee_code=e.employee_code and tw.course_id=tc.id where lower(e.employee_code)=lower('E00113885')
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询