我正在运行 MariaDB 10.3.16 的本地主机 XAMPP 设置,并编写了以下查询,该查询根据第一个表的“ID”列从多个表中删除行。问题是,昨天还运行得很好,今天在相同的测试数据上根本不会产生任何影响。
我在本例中重命名了表,但其他一切都相同。假设我们尝试删除当前存在的多个 ID 48、49 和 50:
delete t1,t2,t3,t4,t5,t6,t7,t8 from table1 as t1
join table2 as t2 on t2.account_id = t1.id
join table3 as t3 on t3.account_id = t1.id
join table4 as t4 on t4.account_id = t1.id
join table5 as t5 on t5.account_id = t1.id
join table6 as t6 on t6.account_id = t1.id
join table7 as t7 on t7.account_id = t1.id
join table8 as t8 on t8.account_id = t1.id
where t1.id in (48,49,50);
我现在有点抓狂,因为这个查询昨天多次运行良好,因为我在各个表中添加行来测试它。每次都有效。今天,我在项目的一个完全不相关的部分做了一些其他工作,然后回到使用 API 的 DELETE 端点 - 结果发现这个查询根本不会再删除任何东西。一切顺利,但现在影响 0 行。
将查询直接复制并粘贴到 phpMyAdmin(它也曾经在其中工作)给出了相同的结果 - 0 行受到影响。
我的查询有问题吗?你会以不同的方式写这个吗?
是否有任何原因可以解释为什么相同的查询、在相同的环境中、使用相同的测试数据,有一天可以工作,而第二天就不行了?也许是一个小故障?
不负相思意
相关分类