Domanda

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    |
---+----------+---
È stato utile?

Soluzione

you could use FIND_IN_SET, like:

$searchterm = 6;
$where = "FIND_IN_SET('".$searchterm."', id)";  
$this->db->where( $where );
$this->db->get('mytable');  
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top