我正在尝试使用 implode 函数中的数组运行查询。
$dosages = implode(" AND CONCAT(prescription,'-',dosage) =",$doses);
$q=$this->db->query("SELECT account_num
FROM (
SELECT account_num, CONCAT(prescription,'-',dosage) as script
FROM ci_prescription_history
)a
WHERE script=".implode(' AND script=',$doses));
MySQL 一直在说“'where 子句'中的未知列'Advair'”。我只是想知道是否可以用单引号将变量包装在 implode 函数中,所以当它被解析时,它会像这样读出
SELECT account_num
FROM ( SELECT account_num, CONCAT(prescription,'-',dosage) as script
FROM ci_prescription_history
)a
WHERE script='Advair-230/21' AND script='Advair-250/50'