$this->db->select('header.*,customer.*,destination.location');
$this->db->from(self::WAYBILL_HEADER_TABLE. " as header");
$this->db->join(self::CUSTOMER_TABLE." as customer","header.consignee = customer.id");
$this->db->join(self::WAYBILLDESTINATION_TABLE. " as destination","header.destination_from = destination.id",'INNER');
$this->db->join(self::WAYBILLDESTINATION_TABLE. " as destinations","header.destination_to = destinations.id",'INNER');
$this->db->where('header.waybilldate <=',$date_to);
$this->db->where('header.waybilldate >=',$date_from);
$this->db->order_by('header.waybillno','DESC');
$query = $this->db->get()->result();
return $query;
答案 0 :(得分:0)
试试这个
$this->db->join('t2', 't1.x = t2.c', 'left');
答案 1 :(得分:0)
您的问题不明确,但要将两列合并为一列,您可以在select语句中使用CONCAT函数,如下所示
$this->db->select('table_name.column1, CONCAT(table_name.column2, ' ', table_name.column3) as table_name.twoInOne');
这只是一个如何使用concat
功能的想法。此外,对于群组联合检查this answer。
答案 2 :(得分:0)
尝试:
$ this-&gt; db-&gt; query(“SELECT CONCAT(column1,'',column2)FROM employee_tbl”);
http://www.tutorialspoint.com/mysql/mysql-concat-function.htm
答案 3 :(得分:0)
我建议在同一张表中联接两个或更多列:
$this->db->select("*");
$this->db->from("follows");
$this->db->join('users table1','table1.user_id=follows.following_id','left');
$this->db->join('users table2','table2.user_id=follows.follower_id','left');
$this->db->where("table1.is_active",1);
$this->db->where("table2.is_active",1);
$res=$this->db->get();
return $res->result();