prepare('SELECT * FROM mytable WHERE mycol IN (:mystr)'); $stmt->execute(['mystr' => $mystr]);` Whe" /> prepare('SELECT * FROM mytable WHERE mycol IN (:mystr)'); $stmt->execute(['mystr' => $mystr]);` Whe" /> prepare('SELECT * FROM mytable WHERE mycol IN (:mystr)'); $stmt->execute(['mystr' => $mystr]);` Whe"/>

php mysql syntax with IN

32 views Asked by At

Why dosnt this work:

$mystr = "1,2";
$stmt = $pdo->prepare('SELECT * FROM mytable WHERE mycol IN (:mystr)');
$stmt->execute(['mystr' => $mystr]);`

When this does:

$mystr = "1,2";
$stmt = $pdo->prepare('SELECT * FROM mytable WHERE mycol IN ('.$mystr.')');
$stmt->execute();

Try and error and search the Internet

0

There are 0 answers