2017-09-26 31 views
0

我想從ms_prod_harga
得到msph_pl場,這是我的模型宣傳片LEFT JOIN模型笨

這是正確的?

$this->db->select('*'); 
    $this->db->from('md_promo');     
    $this->db->join('ms_promo','mspr_no = mdpr_mspd_no','left'); 
    $this->db->join('ms_produk','mspd_no = mspr_no','left'); 
    $this->db->join('ms_prod_harga', 'mspr_no = msph_no','left'); 

    $this->db->where('mdpr_no',$mspr_no);  

回答

0

如果你的表是這樣的:

(表)md_promo (值)mspr_no

(表)ms_produk (值)mspd_no

(表)ms_prod_harga (值)msph_no

而且,如果您需要將來自ms_prod_ha的msph_pl(value)結果RGA(表),那麼這段代碼應該工作:

$this->db->select('*'); 
$this->db->from('md_promo'); 
$this->db->join('ms_prod_harga', 'md_promo.mspr_no = ms_prod_harga.msph_no', 'left'); 
$this->db->join('ms_produk', 'md_promo.mspr_no = ms_produk.mspd_no', 'left'); 

$query = $this->db->get(); 
echo "<pre>" . var_export($query->result_array(), true) . "</pre>"; // display the result_array in elegant form 

希望幫助,但是,它可能不是你真正需要的是什麼..

+0

感謝哥們.. –

+0

如果這是回答你的問題,你可以確認這一點 – user268500