如何使用 codeigniter 的事件记录运行 select * from table where col1+col2=b;
。使用mysql
我尝试过但失败了
$this->db->where("col1 + col2",$b)->get("table")->result_array();
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '915087' at line 4
SELECT * FROM
table
WHERE a + b 25
最佳答案
You can do that how you were thought. Just fixed out your mistake follow the below code. Thanks. If it's useful please acknowledge it.
$b = 25;
$data = $this->db->where(array("(number1 + number2) = " => $b))->get("dummy_table")->result_array();
echo "<pre>";
print_r($data);
// output
Array
(
[0] => Array
(
[id] => 1
[number1] => 10
[number2] => 15
[number3] => 25
)
[1] => Array
(
[id] => 2
[number1] => 23
[number2] => 2
[number3] => 25
)
[2] => Array
(
[id] => 3
[number1] => 9
[number2] => 16
[number3] => 25
)
[3] => Array
(
[id] => 4
[number1] => 23
[number2] => 2
[number3] => 25
)
)
关于php - 如何使用事件记录从表中选择 *,其中 col1+col2=b,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41237802/