我想用选择加入与TABLE_A和表-B和加入table_A.in_no = table_B.in_no,这In_no的差值。如何使用右选择连接两个表来指定codeigniter中连接值的最后一个字符?
例子:在表-A In_no值= ISP1501-1
而在表-B In_no值= 1
所以我想加入就in_no在TABLE_A In_no的最后一个字符用其exsprestion相比-1就像我的图片一样,但我无法做到。
Codeigniter是否为这种情况提供了一些解决方案?
在我的模型
public function select_in_completed(){
$this->db->select('add_val.*, invoice_all.*');
$this->db->from('add_val');
$this->db->join('invoice_all','invoice_all.in_no = add_val.in_no');
$this->query = $this->db->get();
if($this->query->num_rows()>0){
return $this->query->result();
}
}
并在cotroller
public function index() {
if($this->logged_in ==TRUE){
if($this->user_type == "editor"){
$this->load->model('frontend/report_m');
$this->data['user_id'] = $this->user_id;
$this->data['invoice'] = $this->report_m->select_in_completed();
$this->data['subview'] = 'invoice/invoice';
$this->load->view('frontend/report/complet/view_incom', $this->data);
}else{
redirect(base_url('user/login'));
}
}else{
redirect(base_url('user/login'));
}
}
我使用视图与简单的代码的foreach函数来获取所有数据
如果我知道在两个表中的值相同In_no的矩形值,将工作
所以我想问一下在#1的所有成员。它可能与否?
感谢您的帮助。
我不明白你的变量$表[9] –
对不起,我忘了给解释....这里从数据库中的字段日期是isp1501-39在那里权!!!!! ......当我们将分割最后一个值的时候会是这个数组[9] –
我选择多于4000rows如果我用比较多的话会慢一点吧?我希望没有问题 –