how to delete multiple records with one query
i would like to delete multiple records with one query using mysql and php instead of using any loops.
$query = "DELETE FROM countries c WHERE c.id =开发者_Python百科 8";
what is the syntax for that?
$query = "DELETE FROM countries c WHERE c.id in(4,5,6,7,8,89,9, ....)";
$query = "DELETE FROM countries c WHERE c.id > 5 and c.id < 25";
I think you should use
$query = "DELETE FROM countries c WHERE c.id = 8 OR c.id = 9 OR c.id = 10";
Didn't test this code but I think it should work.
If you know all of the id's you can say "WHERE c.id in (8,9,10)"
精彩评论