Update fields based on conditions

UPDATE opportunity
        INNER JOIN opp_stage_checklist
        ON opportunity.id = opp_stage_checklist.opp_id AND opportunity.stage_number = opp_stage_checklist.stage_number
        <set>
            opportunity.status_code = 3,opportunity.update_date = NOW()
        </set>
        WHERE ( DATE_ADD(opp_stage_checklist.check_time, Interval opp_stage_checklist.offset_value month)) < NOW()
        AND opportunity.stage_number = 2 AND !(opportunity.status_code = 3 OR opportunity.status_code = 4);

 

UPDATE opportunity
        <set>
            status_code = #{statusCode}, update_date = NOW()
        </set>
        WHERE id IN
        <foreach item="item" index="index" collection="oppIds" open="(" separator="," close=")">
            #{item}
        </foreach>

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326196425&siteId=291194637