I use PHP to parse big CSV file and generate a SQL file that contains INSERT
requests.
But at the beginning of the file, I also put a DELETE
statement to clear the database before.
My file looks like something like this :
DELETE FROM `my_table` WHERE id IN (<list>) ;
INSERT INTO `my_table` .... (lot of values);
The lines are correctly inserted but the old ones are not deleted. I tried the delete request in PHPMyAdmin : it works. So the issue comes from the way I run the sql file.
I use the exec
method in PHP :
$command = "mysql.exe -u user -pPassword my_database < sqlfile.sql";
It seems that this line, using the left chevron, works fine for INSERT statements, but not for DELETE ones.
Any idea to solve that ?
Thanks a lot :)