codeigniter - 如何在codeigniter中计算两个表上的子字符串
问题描述
我有两张桌子
table1 id|name|next_field
table2 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 = info1, info2, next,...
现在我想以与第一个查询相同的方式检查例如“info2”作为 table1.next_field 中的一部分的频率
有没有可能,怎么做?
解决方案
毕竟我决定改变我的数据库结构以使工作和处理更容易。
推荐阅读
- reactjs - 如何在反应中将最新状态从子组件传递给父组件
- c# - 如何将多个 PictureBox 一起移动?
- c# - 如何使此图像居中
- spring-jdbc - 通过使用 Spring jdbc 模板调用多个过程来实现事务
- python - 全局变量的可用深度有多深?
- python-3.x - 如何在函数执行完成后引发异常并捕获它?
- flutter - 如何在 microsoft graph api 中添加二进制数据以使用上传会话上传文件
- c++ - 检查模板化成员函数是否存在 SFINAE
- php - 为 Json 从 MYSQL 中分离检索到的数据(为 API C# 做准备)
- c# - 在 DotNetCore 3.0 中分页不返回任何结果