Usage of FIND_IN_SET in query [closed]

人盡茶涼 提交于 2019-12-12 01:48:58

问题


  $query=$this->db
->select(a.date,group_concat(s.name)
->from("tbl_attendance a,tbl_students s") 
->WHERE ("FIND_IN_SET(s.student_id, a.attendance)")->group_by("a.date")
->get();

I wanted to know whether I have used the FIND_IN_SET and group_by functions correctly. Thanks in advance


回答1:


FIND_IN_SET() returns the position of a string if it is present (as a substring) within a list of strings

so you should search if a value is != 0

eg:

->where("FIND_IN_SET(s.student_id, a.attendance) !=", 0)
->group_by("a.date")


来源:https://stackoverflow.com/questions/43295235/usage-of-find-in-set-in-query

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!