我在join的帮助下从3个表中获取数据。我的输出是JSON格式。
以JSON格式输出: -
{" order_id":" 2"," location_address":"测试位置德里"," emp_first_name" :"的兰吉特"" ORDER_STATUS":" 0"" FROM_DATE":" 0000 -00-00 00:00:00","动作":" \ r \ n< / i>编辑< / a> \ r \ n \ r \ n< / i>删除< / a>"},
{" order_id":" 2"," location_address":"测试位置德里"," emp_first_name" :"的 abhijeet "" ORDER_STATUS":" 0"" FROM_DATE":" 0000 -00-00 00:00:00","动作":" \ r \ n< / i>编辑< / a> \ r \ n \ r \ n< / i>删除< / a>"},
问题是,在上面的输出中,所有数据都是相同的但是emp_first_name是不同的,因为它们都具有单独的id。现在我想组合emp_first_name的数据并将其显示为单个输出,如
我想要的输出: -
{" order_id":" 2"," location_address":"测试位置德里"," emp_first_name" :"的兰吉特,abhijeet "" ORDER_STATUS":" 0"" FROM_DATE":&#34任何时间00:00:00","行动":" \ r \ n< / i>编辑< / a> \ r \ n \ r \ n< / i>删除< / a>"},
我使用的Query: -
$this->datatables->select('o.order_id, concat_ws(" " , `l.location_street`, `l.location_city` ) as location_address, e.emp_first_name, o.order_status, o.from_date')
->from('orders o')
->join('location l', 'o.location_id = l.location_id')
->join('order_details od', 'od.order_id = o.order_id')
->join('employee e', 'e.emp_id = od.emp_id');
任何帮助将不胜感激。提前谢谢。