$array = array('classesID' => 6);
$this->db->select()->from($this->_table_name)->where($array)->order_by($this->_order_by);
$query = $this->db->get();
return $query->result();
我需要获取classesID为6的行。有些行包含6,5,4。 所以我需要使用FIND_IN_SET查询来检索classesID为6的位置。
请指导我
谢谢
最佳答案
我需要获取学生 ID 为“4488”且消息 ID 为“1418”的行
$id = 1418;
$student_id = 4488;
this->db->select('id, action_status, updated_on, student_ids');
$this->db->where('message_id', $id);
$this->db->where('find_in_set("'.$student_id.'", student_ids) <> 0');
$this->db->from('actions_history');
$query = $this->db->get();
它将返回类似的查询
SELECT id, action_status, updated_on, student_ids FROM actions_history WHERE message_id = '1418' AND find_in_set("4488", student_ids) <>0
关于php - 如何在 codeigniter 查询中使用 FIND_IN_SET?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46509723/