簡體   English   中英

獲取聯接中兩個表的相同字段名稱值

[英]Get same field name values of two tables in join

我有兩個表格,分別是送貨地址和帳單地址。 我對這些表使用聯接。 但不幸的是兩個表的字段名稱相同。我想回顯這兩個數據。

$this->db->select('a.*,b.*,c.*');
        $this->db->from('pr_order_products as a');
        $this->db->join('cust_bill_address as b','a.user_id = b.cust_id','inner');
        $this->db->join('cust_ship_address as c','a.user_id = c.cust_id','inner');
        $this->db->where($cond);
        $query = $this->db->get();
        echo $this->db->last_query(); exit;
        return $query;

如果我獲取結果並echo $order->cust_id; 意味着它只從billing_address表中獲取。有什么辦法嗎?

在選擇語句中顯式設置數據字段:

$this->db->select('
a.cust_id as a_cust_id,
b.cust_id as b_cust_id,
c.cust_id as c_cust_id, 
etc...');

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM