SELECT * FROM abc WHERE (abc LIKE '%value%' OR def LIKE '%value%') AND ghij NOT IN ('1', '2')
答案 0 :(得分:3)
您可以转换此查询:
SELECT * FROM abc
WHERE (abc LIKE '%value%' OR def LIKE '%value%') AND ghij NOT IN ('1', '2')
进入Codeignitor
:
$this->db->select();
$this->db->from('abc'); // FROM table
$this->db->like('abc', '%value%', 'both'); //WHERE LIKE
$this->db->or_like('def', '%value%'); //WHERE OR LIKE
$this->db->where_not_in('ghij', array('1', '2')); //WHERE NOT IN
$query = $this->db->get();
$result = $query->result_array(); // RESULT IN ARRAY
print_r($result);