作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一维数组 $abc。
$abc = array (90, 91, 92, 93, 94, 95, 96, 97, 98, 99);
我想在 WHERE IN 中使用它
SELECT *
FROM table
WHERE columnA IN ()
while (){
$def[] = $row['def'];
}
当我使用简单的 IN('$abc') 时,我有一个响应 - undefined variable :def
如何正确地做到这一点?
最佳答案
您可以使用implode()
函数:
$abc = array (90, 91, 92, 93, 94, 95, 96, 97, 98, 99);
$str = implode(',', $abc);
现在您可以在 IN
子句中使用 $str
。
详细了解implode()
功能。
关于php - mySQL WHERE IN 与数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9327164/
我是一名优秀的程序员,十分优秀!