我有一个问题,我有一个varchar字段,其中包含以逗号分隔的m个值:
garage 1,2
garage 1,3,5
我有以下查询
select
json_object(
'data',
json_objectagg(
r.slug,
json_object(
'nome',r.name,
'localizacao',
json_object(
'endereco' , r.address,
'bairro' , r.neighborhood,
'cidade' , r.city,
'estado' , r.state,
'latitude' , r.lat,
'longitude' , r.lng
),
'tipo' , r.type,
'incorporadora' , d.name,
'dormitorios', json_object('legenda', r.rooms, 'quantidade', json_array(r.rooms_quantity)),
'garagem', json_object('legenda', r.garage, 'quantidade', json_array(r.garage_quantity)),
'metragem', json_object('legenda', r.footage, 'minimo', r.min_footage, 'maximo', r.max_footage),
'preco', json_object('minimo', IFNULL(r.min_value, 0), 'maximo' , IFNULL(r.max_value, 0)),
'capa' , ri.filename_default
)
)
) as jsonExport
from realties r
inner join developers d on r.developer_id = d.developer_id
inner join realties_images ri on r.realty_id = ri.realty_id and ri.type_image = 'cover'
where r.active = 'yes' and d.active = 'yes' and ri.active = 'yes';
但是当返回带有整数的json_array
时,引号不匹配。
是这个["2,Studio"] ["1,2,3"]
但是我需要将其作为一个数组,因为其他代码将获取信息并且我需要它
["2","Studio"] ["1","2","3"]
我已经尝试过array_objectagg
,并且一切都可以,有人可以帮助我吗?