MySQL - UPDATE query based on SELECT Query

后端 未结 11 2075
既然无缘
既然无缘 2020-11-21 23:58

I need to check (from the same table) if there is an association between two events based on date-time.

One set of data will contain the ending date-time of certain

11条回答
  •  执念已碎
    2020-11-22 00:32

    For same table,

    UPDATE PHA_BILL_SEGMENT AS PHA,
         (SELECT BILL_ID, COUNT(REGISTRATION_NUMBER) AS REG 
           FROM PHA_BILL_SEGMENT
            GROUP BY REGISTRATION_NUMBER, BILL_DATE, BILL_AMOUNT
            HAVING REG > 1) T
        SET PHA.BILL_DATE = PHA.BILL_DATE + 2
     WHERE PHA.BILL_ID = T.BILL_ID;
    

提交回复
热议问题