is this possible ? two columns in one columns on table ?
$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;
Try this
$this->db->join('t2', 't1.x = t2.c', 'left');
Your question is not clear but to join two columns in one you may use CONCAT function in your select statement like this
$this->db->select('table_name.column1, CONCAT(table_name.column2, ' ', table_name.column3) as table_name.twoInOne');
This is just an idea how you can use concat
function. Also, for group concat check this answer.
try:
$this->db->query("SELECT CONCAT(column1,' ',column2) FROM employee_tbl");
This solution is described at http://www.tutorialspoint.com/mysql/mysql-concat-function.htm
I suggest to join two or more columns in same table:
$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();