![](/img/trans.png)
[英]Trying to select records from mysql using php, the results are in json without the identifiers
[英]Delete multiple records with different identifiers from a large table without using loop mysql php
我有一百萬行表。 我需要刪除具有等於 15k 長列表中的值之一的特定列的所有行。
現在我將它設置為:
$list = array(
"Item1",
...
"Item15000"
);
foreach ($list as $item){
$sql = "Delete from table where `item`='$item'";
if ($con->query($sql) === TRUE) {
echo "$item removed from table <br>";
} else {
echo "Error removing $item from shop_meta: " . $con->error . "<br>";
}
}
在目前的狀態下,它需要很多小時才能完成,而且我也必須為許多其他類似的表做這件事。
如何加快或優化查詢? 有沒有辦法一次查詢它們以更快地完成它?
將那些 15k 列表放在一個表中,然后加入它
Delete t
from your_table t
join temp_table tt on t.item = tt.delete_value
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.