如何一次删除2个表

时间:2012-07-22 13:12:48

标签: mysql

我想使用WHERE department ='something'

一次删除2个表记录

我试试这个并没有用:

DELETE FROM departments, categories 
WHERE department.department = 'something' 
AND categories.department = 'something';

3 个答案:

答案 0 :(得分:0)

DELETE FROM departments INNER JOIN categories
    WHERE departments.department = categories.department 
        and department.department = 'something'

答案 1 :(得分:0)

使用此声明解决了问题:

  

删除部门。 *,类别。 *来自部门,类别   departments.department ='{$ dept_name}'AND   categories.department ='{$ dept_name}'

答案 2 :(得分:0)

DELETE FROM departments
JOIN categories ON departments.department = categories.department
WHERE department.department = 'something'`