$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();
我有像2018121011430, 201812101140, 201812101141
这样的招聘人员ID。现在,我想使用更新查询删除201812101140
。这是我的查询,但它不起作用。如何从列recruiter_id
中删除201812101140
?
在mysql中,替换函数语法为REPLACE(field_name,string_to_find, string_to_replace)
。
你必须用空格代替逗号。您的查询应该是这样的。
UPDATE job_registration SET recruiter_id=replace(recruiter_id,',','') WHERE job_id='jid1205161020' and recruiter_id like '%20181130070940%'
$data = array(
'recruiter_id' => ''
);
$this->db->where('jid', $this->input->post('jid'));
$this->db->where('recruiter_id', 201812101140);
$this->db->update('job_registration', $data);