我正在尝试使用PHP mysqli prepared语句找到删除多行的解决方案。目前,我的代码会从一个表中删除记录。从多个表中删除行的结构是什么?
以下是我的代码示例:
`$sql ='DELETE FROM itm_pic_detail WHERE itm_pic_detail.id = ?';`
我将如何编写以下语法:
DELETE FROM itm_pic_detail, itm_details, itm_ref, itm_value WHERE itm_pic_detail.id = ?, itm_details.id =?, item_ref.desc_id = ?, itm_ref.id = ?
答案 0 :(得分:1)
以下是我在某处使用的查询...请根据您的要求在更改字段后尝试...
示例1
DELETE user,items,orders FROM user LEFT JOIN items ON user.us_id = items.us_id LEFT JOIN orders ON items.od_id = orders.od_id WHERE user.us_id = $usrID
示例2
以下是我想做的事情......
DELETE FROM table1 WHERE data_id='111';
DELETE FROM table2 WHERE data_id='111';
DELETE FROM table3 WHERE data_id='111';
为此,我使用下面的代码
DELETE FROM table1, table2, table3
USING table1
INNER JOIN table2 USING(data_id)
INNER JOIN table3 USING(data_id)
WHERE table1.data_id = 111
祝你好运!!!
答案 1 :(得分:0)
从多个表中删除行的结构是什么?
如果表没有关系 - 您只需执行多个DELETE
个查询。执行2次查询以从2个不同的表中删除行