开发者

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)"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜