我有2张桌子。 table1有200万条记录,table2有1100万条记录我想从table2删除table1我是如何在MySQL中执行此操作的,对于这个数据计算需要多少钱? 谢谢。
答案 0 :(得分:2)
听起来您想要删除表2中与表1中的记录匹配的所有记录。如果是这样,您可以使用子查询。我不确定你的记录数量会有多高效,但以下情况应该有效:
DELETE FROM table2 where table2.phonenumber IN (select phonenumber from table1);
答案 1 :(得分:1)
SELECT Table2.* FROM Table2 JOIN Table1 ON Table2.phone = Table1.phone WHERE Table2.phone is not null
DELETE Table2.* FROM Table2 JOIN Table1 ON Table2.phone = Table1.phone WHERE Table2.phone is not null
答案 2 :(得分:1)
Delete from table2
where number in (Select number from table1)
答案 3 :(得分:0)
尝试进行连接,然后从连接中删除
SELECT tbl1.MyId FROM table1 tbl1
JOIN table2 on tbl1.phonenumber = tb2.phonenumber
然后从
中删除如
DELETE FROM Table2 WHERE MyID IN
(SELECT tbl1.MyId FROM table1 tbl1
JOIN table2 on tbl1.phonenumber = tb2.phonenumber)
这是sql代码,不完全确定mysql中有什么变化
祝你好运!