Home  >  Article  >  Backend Development  >  php查询条件为一维数组

php查询条件为一维数组

WBOY
WBOYOriginal
2016-06-23 13:47:191306browse

PHP查询条件where id = array(1,2,3)怎么做


回复讨论(解决方案)

where id in (1,2,3)

$id = implode(',', array(1,2,3));
$sql = "....where id in ($id) ";

使用in可以

$id = array(1,2,3);$sqlstr = "select * from table where id in(".implode(',',$id).")";

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn