How to delete all the records (rows) with more than one condition from a table with PDO in PHP

1 Answer

0 votes
try 
{
    $con = new PDO("mysql:host=".$db_host.";dbname=...");
    
    $count = $con->exec("DELETE FROM table_name WHERE category_id = 13 AND product_name <> 'microsoft office 2016'");

    echo "Delete $count rows <br />";
}
catch (PDOException $e) 
{
    echo $e->getFile() . " : " . $e->getLine() . " : " . $e->getMessage();
}

/*
run: 

Delete 5 rows 

*/

 



answered Jul 1, 2016 by avibootz
...