Php 删除id位于逗号分隔字符串中的行

Php 删除id位于逗号分隔字符串中的行,php,mysql,Php,Mysql,我需要删除id位于逗号分隔字符串中的所有行 $ids = '1,2,3,4,5'; $sql = "delete from images where id in(:aid)"; $st = $db->prepare($sql); $st->execute([ ":aid" => $ids ]); 结果-仅删除一行。与一起使用 或使用 如果使用,则可以将逗号分隔的字符串视为字符串。$ids=explode(“,”,$ids)?如果您想使用在\u集合中查找\u,下面是一

我需要删除id位于逗号分隔字符串中的所有行

$ids = '1,2,3,4,5'; 
$sql = "delete from images where id in(:aid)";
$st = $db->prepare($sql);
$st->execute([
    ":aid" => $ids
]);
结果-仅删除一行。

与一起使用

或使用


如果使用,则可以将逗号分隔的字符串视为字符串。
$ids=explode(“,”,$ids)?如果您想使用
在\u集合中查找\u
,下面是一个最终有效的示例,非常感谢
$st->execute([
    ":aid" => "'".implode("','", explode(",",$ids))."'"
]);
$sql = "Delete from images WHERE FIND_IN_SET(`id`, :aid)";
$st = $db->prepare($sql);
$st->execute([
   ":aid" => $ids
]);