dongmen1925
2017-07-14 09:48
浏览 123
已采纳

在codeigniter中使用多个where条件更新表

I have to update the table if only the three values gets matched. I get a syntax error on trying this. What could be the reason?

 $sql1="update target set updvalue='".$val3."'  where Id ='".$b."'" AND MId ='".$c."'" AND DID ='".$f."'";
 $res1=$this->db->query($sql1);
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • doulian1852 2017-07-14 09:53
    已采纳
    $sql1="update target set updvalue='".$val3."'  where Id ='".$b."' AND MId ='".$c."' AND DID ='".$f."'";
    $res1=$this->db->query($sql1);
    

    use this

    已采纳该答案
    评论
    解决 无用
    打赏 举报
  • dquoj04882 2017-07-14 09:53

    I think there are to many " between where Id and AND, that is, you have made a typo.

    评论
    解决 无用
    打赏 举报
  • douciping4283 2017-07-14 10:01

    You can use Codeigniter query builder.

    $this->db->where('Id',$b);
    $this->db->where('MId',$c);
    $this->db->where('DID',$f);
    $upd_data['updvalue'] = $val3;
    $res1=$this->db->update('target',$upd_data);
    

    Let me know if it not works.

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题