Reputation: 805
My value stored in the database looks like this ["7","8"]
and i want to check if my search value is present in it for that i had used my code like this
$this->db->where_in(json_decode('tool_id'),$tool_id);
$this->db->where('status',0);
$query=$this->db->get('tbl_tools_supplied');
return $query->result();
my all values are stored like this in tool_id
column here its not getting the output so is there any other way
Upvotes: 1
Views: 558
Reputation: 51
This works for me
SELECT * FROM table_name WHERE FIND_IN_SET("7", REPLACE(REPLACE(tool_id,'[', ''), ']',''))
Upvotes: 1
Reputation: 167
you can not search your id in where condition of sql query if column store data as json,but you can fetch all records and then filter out result array of mysql query by match your id.
Upvotes: 0