SELECT MRO.OP_CODE, MRO.OP_NAME, MRO.STANDARD_TIME, MRO.BEGIN_FLAG, MRO.OP_SEQ, UTO.TASK_DATE, UTO.REPORT_DATE, UTO.PRO_STATE, UTO.GID AS UMPP_TASK_ORDER_GID, WOP.Is_Manual_Reassignment FROM MBF_ROUTE_OPERATION MRO JOIN UMPP_TASK_ORDER UTO on UTO.OP_GID = MRO.GID left JOIN APS_WORK_ORDER_PLAN WOP ON UTO.GID = WOP.UMPP_TASK_ORDER_GID WHERE 1=1 AND MRO.IS_DELETE = 0 AND UTO.IS_DELETE = 0 AND UTO.PRO_STATE = 0 ORDER BY MRO.OP_SEQ 这句sql改为查出WOP表没有关联的的数据或 WOP.Is_Manual_Reassignment等于0的数据行都要查出来 怎么写
时间: 2024-02-18 14:01:03 浏览: 179
Microsoft R open SRS_8.0.3.0_1033.cab 官网原版
可以使用左连接来查出WOP表没有关联的数据或者Is_Manual_Reassignment等于0的数据行,查询语句如下:
```
SELECT MRO.OP_CODE, MRO.OP_NAME, MRO.STANDARD_TIME, MRO.BEGIN_FLAG, MRO.OP_SEQ,
UTO.TASK_DATE, UTO.REPORT_DATE, UTO.PRO_STATE, UTO.GID AS UMPP_TASK_ORDER_GID,
WOP.Is_Manual_Reassignment
FROM MBF_ROUTE_OPERATION MRO
JOIN UMPP_TASK_ORDER UTO ON UTO.OP_GID = MRO.GID
LEFT JOIN APS_WORK_ORDER_PLAN WOP ON UTO.GID = WOP.UMPP_TASK_ORDER_GID AND WOP.Is_Manual_Reassignment <> 1
WHERE MRO.IS_DELETE = 0 AND UTO.IS_DELETE = 0 AND UTO.PRO_STATE = 0 AND WOP.GID IS NULL
ORDER BY MRO.OP_SEQ
```
在左连接中,同时通过条件 WOP.GID IS NULL 来查出WOP表没有关联的数据行,同时通过条件 WOP.Is_Manual_Reassignment <> 1 来查出Is_Manual_Reassignment等于0的数据行。
阅读全文