MYSQL查询以数组形式返回 将查询结果组装成数组、逗号连接或者对象

MYSQL将查询结果组装成数组、逗号连接或者对象

SELECT
  t1.TRUCK_PLAN_CODE,
	t1.DRIVER_CODE,
	t1.DRIVER_NAME,
	t1.DRIVER_PHONE,
	t1.IDENTITY_CODE,
	t1.CAR_NO,
	t1.TRUCK_LOAD_NUMBER,
	t1.LOGISTICS_CODE,
	t2.LOGISTICS_NAME,
	t1.PLAN_OUT_PLANT_TIME ,
	(
	select 
	CONCAT(
    '[', 
    GROUP_CONCAT(JSON_OBJECT('vin', VIN_NO)),
    ']'
	)
	from t_vl_bu_truck_plan_details  where TRUCK_PLAN_ID  = t1.TRUCK_PLAN_ID  
	)  as vinList,
p.TRANSPORT_STATUS ,
lookup1.LOOKUP_VALUE_NAME AS TRANSPORT_STATUS_NAME
FROM
	t_vl_bu_truck_plan  t1
	left join t_vl_db_logistics  t2 on t1.LOGISTICS_CODE=t2.LOGISTICS_CODE and  t2.IS_ENABLE='1'
	left join t_vl_bu_transport_plan p on p.TRUCK_PLAN_ID = t1.TRUCK_PLAN_ID 
LEFT JOIN t_vl_lookup_value lookup1 ON lookup1.LOOKUP_VALUE_CODE=p.TRANSPORT_STATUS AND lookup1.LOOKUP_TYPE_CODE="VL_TRAN_PLAN_STATUS"
WHERE
t1.IS_ENABLE='1'
	and t1.TRUCK_STATUS = '2'
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值