作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
您好,请引用我的模型中的以下代码
public function common_report($where) {
$this->db->select('*');
$this->db->from('collect_data_form_history_db as ch');
$this->db->join('board_artwork_history_db as bh','bh.shop_id = ch.shop_id');
$this->db->where('bh.shop_id', $where);
// $this->db->where('bh.shop_id',$where);
$query = $this->db->get();
return $query->result_array();
}
我想要的是来自表collect_data_form_history_db和board_artwork_history_db的所有数据。我得到了数据,但格式错误。在表“collect_data_form_history_db”中,我有 11 个条目,在 board_artwork_history_db 中,我有 18 个条目。所以我得到的数据应该是 29 行,但我得到 198 行意味着 11 * 18。请告诉我解决办法
最佳答案
您需要使用左连接。试试这个方法
$this->db->join('board_artwork_history_db as bh','bh.shop_id = ch.shop_id', 'left');
关于mysql - 如何在codeigniter中从两个不同的表中选择具有相同列名的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50266848/
我是一名优秀的程序员,十分优秀!