you could use FIND_IN_SET
, like:
$searchterm = 6;
$where = "FIND_IN_SET('".$searchterm."', id)";
$this->db->where( $where );
$this->db->get('mytable');
Вопрос
Using codeigniter active records method, i want to find out which rows contains the id=6.
Pls advise.
$this->db->like('id', 6);
$this->db->get('mytable');
| id |
---+----------+---
| 3,16,8,6 |
---+----------+---
| 6,66 |
---+----------+---
| 7,560 |
---+----------+---
Решение
you could use FIND_IN_SET
, like:
$searchterm = 6;
$where = "FIND_IN_SET('".$searchterm."', id)";
$this->db->where( $where );
$this->db->get('mytable');