Hi,
I would use the following sql
delete from table where id in (value1,value2, ...)
But if the list is to big you might want to inrease the "max_allowed_packet"
configuration variable
Also you can write a simple script to read the values from the file. Here is
an example in PHP
$fp=fopen("filename","r");
if($fp){
while (!feof($fp)){
$line=fgets($fp,4096);
$todelete=$line.",";
}
fclose($fp);
}
if ($todelete){
mysql_query("delete from table where id in
(".substr($todelete,0,-1).")",$db);
}
or if you want to delete the records line by line:
$fp=fopen("filename","r");
if($fp){
while (!feof($fp)){
$line=fgets($fp,4096);
mysql_query("delete from table where id = $line",$db);
}
fclose($fp);
}
HTH
Dobromir Velev
[EMAIL PROTECTED]
http://www.websitepulse.com/
----- Original Message -----
From: "Scott Haneda" <[EMAIL PROTECTED]>
To: "MySql" <[EMAIL PROTECTED]>
Sent: Tuesday, March 25, 2003 09:57
Subject: Deleting a large group of numbered records
> I have a huge text file, \r seperated, for example:
> 10065
> 10066
> 10067
> 10069
> 10070
> 10075
> 10091
> 10093
> 10094
> 10100
> 10103
> 10104
> 10107
> 10108
> 10113
> 10114
> 10115
> 10116
> 10117
> 10118
> 10119
> 10120
> 10121
> 10122
> 10123
> 10124
> However, there are about 5000 numbers in it, I need a way to delete from
> table where old_id = one of the above numbers and then repeat on, is there
a
> easy way to construct this statement, perhaps reading the data from a
> infile.
>
> Mysql
>
> -------------------------------------------------------------
> Scott Haneda Tel: 415.898.2602
> http://www.newgeo.com Fax: 313.557.5052
> [EMAIL PROTECTED] Novato, CA U.S.A.
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]
>
>
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]