Php 将两列连接在一列中,然后使用codeigniter
这可能吗?表上的一列中有两列Php 将两列连接在一列中,然后使用codeigniter,php,sql,codeigniter,Php,Sql,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-&g
$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->select('header.*,customer.*,destination.location');
$this->db->from(self::WAYBILL_HEADER_TABLE.“as HEADER”);
$this->db->join(self::CUSTOMER_表.“作为客户”,“header.收货人=客户.id”);
$this->db->join(self::WAYBILLDESTINATION_表.“作为目的地”,“header.destination_from=destination.id”,“内部”);
$this->db->join(self::WAYBILLDESTINATION_表.“作为目的地”,“header.destination_to=destinations.id”,“内部”);
$this->db->where('header.waybilldate=',$date\u from);
$this->db->order_by('header.waybillno','DESC');
$query=$this->db->get()->result();
返回$query;
试试这个
$this->db->join('t2', 't1.x = t2.c', 'left');
您的问题不清楚,但要将两列连成一列,您可以在select语句中使用如下函数
$this->db->select('table_name.column1, CONCAT(table_name.column2, ' ', table_name.column3) as table_name.twoInOne');
这只是一个如何使用concat
函数的想法。此外,对于组concat检查。请尝试:
$this->db->query(“从employee_tbl中选择CONCAT(column1,,,column2”)代码>
有关此解决方案的说明,请参阅
我建议将同一个表中的两列或多列合并:
$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();
您正在尝试将哪两列合并为一列?您是否正在尝试将同一表中的两列合并为一列。行?是的WAYBILLDESTINATION_表我有2列数据,我想合并为一列您是否在考虑自合并?我想,OP
想要将同一个表中的两列合并到一个表中。行,不是两个表,但我可能也错了。也许您应该对此代码段进行解释。原始代码有什么问题?发生了什么变化?为什么它会起作用?欢迎来到SO!请编辑您的问题并添加一些解释/上下文,请参阅以获取更多指导。