[英]Join two columns in one columns codeigniter
这可能吗 ? 表格中的两列合二为一?
$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;
尝试这个
$this->db->join('t2', 't1.x = t2.c', 'left');
尝试:
$this->db->query("SELECT CONCAT(column1,' ',column2) FROM employee_tbl");
在http://www.tutorialspoint.com/mysql/mysql-concat-function.htm中描述了该解决方案
我建议在同一张表中加入两个或多个列:
$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();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.