UPDATE Z_YIZHU SET SHIFASHULIANG=SHULIANG*3 WHERE YIZHUID IN (SELECT YIZHUID FROM Z_YIZHUFASONG WHERE Shifashuliang='0' AND JIZHANG='1' AND FAYAO='1' AND YDZXSHIJIAN>to_date('2023-05-31 00:00:00','yyyy-MM-dd hh24:mi:ss') AND TUIYAO='0' AND SHENHEJIEGUO='0' AND SHULIANG>='1' and pinchi='0003') AND TINGZHI='0'; UPDATE Z_YIZHU SET SHIFASHULIANG=SHULIANG*2 WHERE YIZHUID IN (SELECT YIZHUID FROM Z_YIZHUFASONG WHERE Shifashuliang='0' AND JIZHANG='1' AND FAYAO='1' AND YDZXSHIJIAN>to_date('2023-05-31 00:00:00','yyyy-MM-dd hh24:mi:ss') AND TUIYAO='0' AND SHENHEJIEGUO='0' AND SHULIANG>='1' and pinchi='0002') AND TINGZHI='0'; UPDATE z_yizhufasong SET JIZHANG = '0', ZHIXING = '0', ZHIXINGYONGHUID = '', ZHIXINGSHIJIAN = '', PEIYAO = '0', PEIYAOKESHIID = '', PEIYAOYONGHUID = '', FAYAO = '0', FAYAOYONGHUID = '', FAYAOKESHIID = '', FAYAOSHIJIAN = '', SHIFASHULIANG = SHULIANG, ZHIXINGLIUSHUIHAO='' where YIZHUID IN (SELECT YIZHUID FROM Z_YIZHU WHERE YIZHUID IN (SELECT YIZHUID FROM Z_YIZHUFASONG WHERE Shifashuliang = '0' AND JIZHANG = '1' AND FAYAO = '1' AND YDZXSHIJIAN > to_date('2023-05-31 00:00:00', 'yyyy-MM-dd hh24:mi:ss') AND TUIYAO = '0' AND SHENHEJIEGUO = '0' AND SHULIANG >= '1') AND TINGZHI = '0' -- AND JINE = '0' ) AND SHULIANG >= '1' AND Shifashuliang = '0' AND JIZHANG = '1' AND FAYAO = '1' AND YDZXSHIJIAN > to_date('2023-05-31 00:00:00', 'yyyy-MM-dd hh24:mi:ss') AND TUIYAO = '0' AND SHENHEJIEGUO = '0';
时间: 2024-02-15 11:29:06 浏览: 108
这是一段包含三个UPDATE语句的SQL脚本。每个UPDATE语句都涉及到两个表:Z_YIZHU和Z_YIZHUFASONG。
第一个UPDATE语句将Z_YIZHU表中符合条件的行的SHIFASHULIANG列的值设置为SHULIANG列的值乘以3。具体条件是:YIZHUID在Z_YIZHUFASONG表中满足条件的记录中,并且TINGZHI列的值为0。Z_YIZHUFASONG表中符合条件的记录的条件是:Shifashuliang列的值为0,JIZHANG列的值为1,FAYAO列的值为1,YDZXSHIJIAN列的值大于'2023-05-31 00:00:00',TUIYAO列的值为0,SHENHEJIEGUO列的值为0,SHULIANG列的值大于等于1,pinchi列的值为'0003'。
第二个UPDATE语句与第一个UPDATE语句类似,但是条件不同。它将Z_YIZHU表中符合条件的行的SHIFASHULIANG列的值设置为SHULIANG列的值乘以2。具体条件是:YIZHUID在Z_YIZHUFASONG表中满足条件的记录中,并且TINGZHI列的值为0。Z_YIZHUFASONG表中符合条件的记录的条件是:Shifashuliang列的值为0,JIZHANG列的值为1,FAYAO列的值为1,YDZXSHIJIAN列的值大于'2023-05-31 00:00:00',TUIYAO列的值为0,SHENHEJIEGUO列的值为0,SHULIANG列的值大于等于1,pinchi列的值为'0002'。
第三个UPDATE语句将Z_YIZHUFASONG表中符合条件的记录的多个列的值更新为指定值。具体条件是:YIZHUID在Z_YIZHU表中满足条件的记录中,并且SHULIANG列的值大于等于1,Shifashuliang列的值为0,JIZHANG列的值为1,FAYAO列的值为1,YDZXSHIJIAN列的值大于'2023-05-31 00:00:00',TUIYAO列的值为0,SHENHEJIEGUO列的值为0。注意,这个UPDATE语句中的子查询会返回Z_YIZHUFASONG表中符合条件的YIZHUID值,并且这些YIZHUID值也符合Z_YIZHU表中的条件。因此,这个UPDATE语句会更新Z_YIZHUFASONG表中与这些YIZHUID值对应的记录。
阅读全文