经典sql
1.查询登录人是产品经理有权限查看的产品
sql1:
select DISTINCT a.real_product_id as realProductId,a.product_code as productCode,a.product_name as productName,
a.product_type as productType,c.invest_direction as investDirection,a.product_managers as productManagers,
a.product_audit as productAudit,c.income_type as incomeType,c.term,c.term_unit as termUnit,c.upper_limit as upperLimit,
a.create_time as createTime, a.product_state as productState
from prod_base_information a
left join prod_product_message c on a.real_product_id = c.real_product_id
left join prod_related_personnel d on a.real_product_id = d.real_product_id
left join prod_related_personnel e on a.real_product_id = e.real_product_id
left join prod_manager b on a.real_product_id = b.real_product_id
where
d.employee_num = 'H018494' and d.product_role = 0 and d.privileges is not null and d.privileges != ''
and e.employee_num = 'H011492' and e.product_role = 0 and e.privileges is not null and e.privileges != ''
sql2:
select DISTINCT a.real_product_id as realProductId,a.product_code as productCode,a.product_name as productName,
a.product_type as productType,c.invest_direction as investDirection,a.product_managers as productManagers,
a.product_audit as productAudit,c.income_type as incomeType,c.term,c.term_unit as termUnit,c.upper_limit as upperLimit,
a.create_time as createTime, a.product_state as productState, d.productManagers,d.employee_num
from prod_base_information a
left join prod_product_message c on a.real_product_id = c.real_product_id
left join
(select p.real_product_id,GROUP_CONCAT(p.employee_name) productManagers,GROUP_CONCAT(p.employee_num) employee_num from prod_related_personnel p
where p.product_role = 0 and p.privileges is not null and p.privileges != ''
GROUP BY p.real_product_id
) d on d.real_product_id = a.real_product_id
left join prod_manager b on a.real_product_id = b.real_product_id
where
d.employee_num like '%H018494%'
and d.employee_num like '%H011492%'