能用一个语句得到结果吗?
各位老大好,我有一个数据表E,里面的字段MERGE ORDER FLAG是有些空白的,会在每天从另一个表OB_LIST_E中更新。为提高效率写了2个查询:
1、得到E里面MERGE ORDER FLAG空白而OB_LIST_E里非空白的,取ORDER_NUM
和MERGE ORDER FLAG两个字段
SELECT OB_LIST_E.[MERGE ORDER FLAG], OB_LIST_E.ORDER_NUM
FROM E INNER JOIN OB_LIST_E ON E.ORDER_NUM=OB_LIST_E.ORDER_NUM
WHERE (((E.[MERGE ORDER FLAG]) Is Null) AND ((OB_LIST_E.[MERGE ORDER FLAG]) Is Not Null));
2、利用查询1的结果,更新E中的MERGE ORDER FLAG字段,ORDER_NUM是唯一的。
UPDATE E INNER JOIN 找出缺少组配类型的查询 ON E.ORDER_NUM = 找出缺少组配类型的查询.ORDER_NUM SET E.[MERGE ORDER FLAG] = 找出缺少组配类型的查询.[MERGE ORDER FLAG];
有没办法用1句解决?
[解决办法]
update a set [MERGE ORDER FLAG]=b.[MERGE ORDER FLAG]
from E a inner join OB_LIST_E b ON a.ORDER_NUM=b.ORDER_NUM
WHERE (((a.[MERGE ORDER FLAG]) Is Null) AND ((b.[MERGE ORDER FLAG]) Is Not Null));