我有两张表,即送货地址和帐单邮寄地址。我使用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表。有什么方法可以吗?
答案 0 :(得分:1)
在select语句中明确设置数据字段:
$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...');