MySQL-EXISTS-DELETE-NOT EXISTS主表根据副表是否还有关联数据来删除主表数据
[NOT] EXISTS主表根据副表是否还有关联数据来删除主表数据
<delete id="delIntentServiceByPkId" parameterType="String">
DELETE s FROM ts_maintain_intent_service s WHERE s.pk_id = CAST(#{pkId} as unsigned)
AND NOT EXISTS(SELECT id_intent_service FROM ts_maintain_intent_service_detail td
WHERE td.id_intent_service = CAST(#{pkId} as unsigned))
</delete>
来自maintain项目
正文到此结束