difference between where_in and find_in_set

后端 未结 3 1708
暗喜
暗喜 2021-01-24 18:09

I am working on a join query in which I have to get the data from a column which contain the comma separated values.like allowed_activity contain 1,2,3,4,5,6<

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-24 18:53

    FIND_IN_SET search for a value in a array and return the index of the value then if the function is different than 0 this mean that the value in present in the list . so the code

      this->db->where("FIND_IN_SET(6, a.allowed_activity) !=",0);
    

    mean return the index of the value 6 in a.allowed_activity
    and if the value return is different that 0 then the value 6 is present in a.allowed_activity

    WHERE ... IN check if the value in the set but don't return the index .. just return true or false if the value is present or not

提交回复
热议问题