如何使用连接查询从两个表中删除行数据???

时间:2014-03-20 07:38:08

标签: php mysql

sql查询:

table name : donersreport , register


delete from donersreport inner join register on donersreport.id = register.id where donersreport.id = '12';

我想从两个表中删除数据......

O / P:

You have an error in your SQL syntax; check the manual that corresponds to 
your MySQL server version for the right syntax to use near 'inner join register 
on donersreport.id = register.id where donersreport.id = '12' at line 1

3 个答案:

答案 0 :(得分:0)

试试这个:

Yes you can use join in delete query.

Pl refer the following link for solution.

MYSQL - Delete Query with Join

- 感谢

答案 1 :(得分:0)

试试这个:

DELETE t1, t2 FROM t1 INNER JOIN t2 WHERE t1.id = t2.id AND […];

答案 2 :(得分:0)

您可以使用以下代码:

DELETE donersreport,register from donersreport inner join register using(id) where donersreport.id = '12';