开发者

How do I write a MySQL query that looks for elements whose keys are in a PHP array?

One of the conditions for my query is that one of table.id should belong to the array $table_arr. Is there a way that will allow me to implement this? An开发者_如何学Cy ideas will be appreciated.


I'm guessing $table_arr is a PHP array of ints or strings.

<?php
    $query = "SELECT * FROM table WHERE id IN (".implode(", ", $table_arr).")";
    $result = mysqli_query($mysql, $query);

    // etc
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜