我有六个表,我想在一个查询中删除这六个表中的数据。有可能吗?
员工表包含主键 - >的 EMP_ID 即可。 其他五个表教育,家庭,健康,培训和工作各自持有 emp_id 作为他们的外键。
我在下面尝试过这个sql。没有显示错误,但数据仍在数据库中。请帮助我,因为我是新手。感谢
查询:
DELETE employee, family, education, work, training, health
FROM employee INNER JOIN family ON employee.emp_id=family.emp_id
INNER JOIN education ON employee.emp_id=education.emp_id
INNER JOIN work ON employee.emp_id=work.emp_id
INNER JOIN training ON employee.emp_id=training.emp_id
INNER JOIN health ON employee.emp_id=health.emp_id
WHERE employee.emp_id='$id'
答案 0 :(得分:0)
这有效:
DELETE table1
,table2
FROM table1
,table2
WHERE table1.columni = table2.columnj
AND table1.columni = 1