LEFT JOIN t_user ON CONCAT(t_user.company_code, t_user.employee_number) = order_management.order_manager_employee_code LEFT JOIN t_sbu sbu ON sbu.sbu_code = aggregation.sbu_code LEFT JOIN tb_0030032_dt_lm_department order_department ON order_department.tms_organization_code = order_management.office_group_code LEFT JOIN tb_0030032_dt_lm_department project_department ON project_department.tms_organization_code = project.project_office_group_code LEFT JOIN ( SELECT DISTINCT 1 AS request_flag, order_plan_id FROM t_hr_request_overview ) request_overview ON order_management.order_plan_id = request_overview.order_plan_id LEFT JOIN ( SELECT DISTINCT 1 AS employee_flag, contract_l1.entruster_order_plan_id AS order_plan_id FROM tb_0080332_dt_pc_inhouse_contract_order_plan contract_l1 LEFT JOIN tb_0080332_dt_pc_inhouse_contract_order_plan contract_l2 ON contract_l1.trustee_order_plan_id = contract_l2.entruster_order_plan_id LEFT JOIN t_order_plan_employee_detail detail ON contract_l1.trustee_order_plan_id = detail.order_plan_id OR contract_l2.trustee_order_plan_id = detail.order_plan_id UNION SELECT DISTINCT 1 AS employee_flag, order_plan_id FROM t_order_plan_employee_detail ) employee_detail ON order_management.order_plan_id = employee_detail.order_plan_id 翻译代码
时间: 2023-11-17 07:51:57 浏览: 108
以下是对代码的翻译:
```
LEFT JOIN t_user
ON CONCAT(t_user.company_code, t_user.employee_number) =
order_management.order_manager_employee_code
LEFT JOIN t_sbu sbu
ON sbu.sbu_code = aggregation.sbu_code
LEFT JOIN tb_0030032_dt_lm_department order_department
ON order_department.tms_organization_code =
order_management.office_group_code
LEFT JOIN tb_0030032_dt_lm_department project_department
ON project_department.tms_organization_code =
project.project_office_group_code
LEFT JOIN (
SELECT DISTINCT 1 AS request_flag,
order_plan_id
FROM t_hr_request_overview
) request_overview
ON order_management.order_plan_id = request_overview.order_plan_id
LEFT JOIN (
SELECT DISTINCT 1 AS employee_flag,
contract_l1.entruster_order_plan_id AS order_plan_id
FROM tb_0080332_dt_pc_inhouse_contract_order_plan contract_l1
LEFT JOIN tb_0080332_dt_pc_inhouse_contract_order_plan contract_l2
ON contract_l1.trustee_order_plan_id
= contract_l2.entruster_order_plan_id
LEFT JOIN t_order_plan_employee_detail detail
ON contract_l1.trustee_order_plan_id = detail.order_plan_id
OR contract_l2.trustee_order_plan_id = detail.order_plan_id
UNION
SELECT DISTINCT 1 AS employee_flag,
order_plan_id
FROM t_order_plan_employee_detail
) employee_detail
ON order_management.order_plan_id = employee_detail.order_plan_id
```
上述代码的翻译如下:
- 第1个 `LEFT JOIN` 子句连接了 `t_user` 表,将其别名为 `t_user`。连接条件是将 `t_user` 表的 `company_code` 和 `employee_number` 字段拼接后与 `order_management` 表的 `order_manager_employee_code` 字段进行比较。
- 第2个 `LEFT JOIN` 子句连接了 `t_sbu` 表,将其别名为 `sbu`。连接条件是将 `sbu` 表的 `sbu_code` 字段与 `aggregation` 表的 `sbu_code` 字段进行比较。
- 第3个 `LEFT JOIN` 子句连接了 `tb_0030032_dt_lm_department` 表,将其别名为 `order_department`。连接条件是将 `order_department` 表的 `tms_organization_code` 字段与 `order_management` 表的 `office_group_code` 字段进行比较。
- 第4个 `LEFT JOIN` 子句连接了 `tb_0030032_dt_lm_department` 表,将其别名为 `project_department`。连接条件是将 `project_department` 表的 `tms_organization_code` 字段与 `project` 表的 `project_office_group_code` 字段进行比较。
- 第5个 `LEFT JOIN` 子句连接了一个子查询,将其别名为 `request_overview`。子查询返回了一个带有唯一标识列 `request_flag` 和 `order_plan_id` 的结果集。连接条件是将 `order_management` 表的 `order_plan_id` 字段与子查询的 `order_plan_id` 字段进行比较。
- 第6个 `LEFT JOIN` 子句连接了另一个子查询,将其别名为 `employee_detail`。第二个子查询使用了 `UNION` 将两个查询结果合并,并返回一个带有唯一标识列 `employee_flag` 和 `order_plan_id` 的结果集。连接条件是将 `order_management` 表的 `order_plan_id` 字段与子查询的 `order_plan_id` 字段进行比较。
这段代码的目的是进行多个表的连接操作,并根据指定的连接条件筛选出符合要求的记录。最终,返回包含指定字段的结果集。
阅读全文