0%

MySQL多表关联删除

t2和t3数据表中存有他t1表中数据的id

选择删除t1表中的数据以及t2和t3表中相关(task_id)的数据

SQL语句如下:

1
2
3
4
5
DELETE t1, t2, t3
FROM t_satisfaction_followup_patients t1
LEFT JOIN t_hospital_followup_record t2 ON t1.id = t2.relation_id
LEFT JOIN t_manage_call t3 ON t1.id = t3.task_id
WHERE t1.id = '8aa5eeb2529d46d5962d561d3a9beedc'