如何计算 codeigniter 中两个表的子字符串

How to count for a substring over two tables in codeigniter

我有两张桌子

表1 编号|名称|next_field

表2 id|id_of_table1|whatelse

我执行 msql 查询以获取 table1 的所有条目以及 table2 中具有 table2 的条目数。id_of_table1 = table1.id

这是我的查询 - 它工作正常。

$select =array('table1.*', 'COUNT(table2.id) AS `my_count_result`',);
            $this->db->select($select);
            if($id!=false){ $this->db->where('id',$id);  }
            $this->db->from('table1 as t1');
            $this->db->join('table2 as t2', 't1.id = t2.id_of_table1');
            return $this->db->get()->result_array();

现在我有另一个字段,它有逗号分隔的数据 table1.next_field = 信息 1,信息 2,下一个,...

现在我想以与第一个查询相同的方式检查例如“info2”作为 table1.next_field

中的一部分的频率

可以吗,怎么办?

毕竟我决定更改我的数据库结构以使工作和处理更容易。