0

I am trying to put multiple values inside the SQL IN operator with the PDO execute function in my query, but it seems like it doesn't work with what I've tried and doesn't return anything:

// FETCH GAMES TABLE
$allGames = $db->prepare("SELECT * FROM `video_games` WHERE `console` IN (:consoles) ORDER BY `price` DESC");
$consolesQuery = ["PS5", "PC", "NES"];
$allGames->execute([
    ":consoles" => implode(", ", $consolesQuery)
]);

It works only when I put one value inside the $consoleQuery array, but with additionnal values it won't work. Is there a better solution for it? Thank you!

Bashar
  • 27
  • 8

0 Answers0