0

I want to delete a record in my sql with array as inputs with two where statement. I cant find a statement like this one...

"DELETE FROM perpetualinventory WHERE productID= ".implode(',',$productID)" && expiryDate=".implode(',',$expiryDate);

for the suggested answer

 "DELETE FROM perpetualinventory WHERE productID IN (".implode(',',$productID)") AND expiryDate IN (".implode(',',$expiryDate).")";

syntax error, unexpected '") AND expiryDate IN ("' (T_CONSTANT_ENCAPSED_STRING)

Gina Co
  • 23
  • 4

2 Answers2

0

Even it is not suggested you could do this

"DELETE FROM perpetualinventory WHERE productID IN (".implode(',',$productID).") AND  expiryDate IN (".implode(',',$expiryDate).")";
teliaz
  • 97
  • 3
0

This code should work :

DELETE FROM perpetualinventory WHERE productID IN ('".implode($productID,"', '")."') AND expiryDate IN ('".implode($expiryDate,"', '")."')";

Explanation :

DELETE FROM table
WHERE column IN ('".
    implode($array, "'separator'") // separator = ', ' for arrays. Be careful for space after the comma.
."')
AND ...
w3spi
  • 4,380
  • 9
  • 47
  • 80