根据条件更新字段

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)) &lt; 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>

猜你喜欢

转载自gwj41.iteye.com/blog/2382735
今日推荐