0
$data = array(
             'recruiter_id'=>REPLACE(recruiter_id,201812101140,'')
         );
$where = "jid='".$this->input->post('jid')."'";
$this->db->where($where);
$this->db->update('job_registration',$data);
echo $this->db->last_query();

I have recruiter ids like 2018121011430, 201812101140, 201812101141. Now, I want to remove 201812101140 using an update query. Here is my query but it doesn't work. How can I remove 201812101140 from the column recruiter_id?

cheersmate
  • 2,385
  • 4
  • 19
  • 32
Bruce
  • 51
  • 7

2 Answers2

0

In mysql replace function syntax is REPLACE(field_name,string_to_find, string_to_replace).

You have to replace comma with space. Your query should look like this.

UPDATE job_registration SET recruiter_id=replace(recruiter_id,',','') WHERE job_id='jid1205161020' and recruiter_id like '%20181130070940%'
bimal sharma
  • 170
  • 8
-1
$data = array(
    'recruiter_id' => ''
);
$this->db->where('jid', $this->input->post('jid'));
$this->db->where('recruiter_id', 201812101140);
$this->db->update('job_registration', $data);
EvE
  • 734
  • 3
  • 13