我有个疑问
$column = 1234;
$sql = "SELECT * FROM TABLE WHERE COLUMN = ?";
$result = $this->db->query($sql,[$column])->row();
它完全可以工作,但是当我有union子句时,我必须传递参数两次
$sql = "SELECT * FROM TABLE1 WHERE COLUMN = ?
UNION
SELECT * FROM TABLE2 WHERE COLUMN = ?";
$result = $this->db->query($sql,[$column,$column])->result();
我们是否有类似下面的代码来实现上面的结果,其中我只能传递一个值,因为它们都需要相同的值。
$sql = "SELECT * FROM TABLE1 WHERE COLUMN = :column
UNION
SELECT * FROM TABLE2 WHERE COLUMN = :column";
$result = $this->db->query($sql,['column' => $column])->result();
1条答案
按热度按时间6uxekuva1#
您可以用途: