** He hecho este Codigo en SQL pero me da error, no entiendo lo que ocurre, alguien podría ayudarme **
select
influencers.id as 'id',
influencers.name as 'name',
influencers.surname as 'surname',
influencers.email as 'email',
influencers.phone as 'phone',
influencers.image as 'image',
influencers.description as 'description',
influencers.social_network as 'social_network',
concat(
'[',
group_concat(
distinct concat(
'{',
concat('id:', products.id, ','),
concat('name:', products.name, ','),
concat('subtitle:', products.subtitle, ','),
concat('category:', products.category, ','),
concat('height:', products.height, ','),
concat('release_time:', products.release_time, ','),
concat('ships:', products.ships, ','),
concat('description:', products.description, ','),
concat(
'images:',
concat(
'[',
group_concat(
distinct concat(
'{',
concat('id:', products_images.id, ','),
concat('alt:', products_images.alt, ','),
concat('url:', products_images.url, ','),
concat('extension:', products_images.extension, ','),
concat('status:', products_images.status, ','),
concat('date:', products.date, ','),
'}'
)
),
']'
),
','
),
concat('price:', products.price, ','),
concat('status:', products.status, ','),
concat('date:', products.date),
'}'
)
),
']'
) as 'products',
influencers.status as 'status',
DATE_FORMAT(influencers.date, "%W %e %M %Y") as 'date'
from
influencers
left join products on products.influencer = influencers.id
left join products_images on products_images.product_id = products.id
group by
influencers.id;
Mi objetivo es obtener la siguiente estructura de la consulta, pero en cambio me da el error que esta como titulo, he intentado modificar mil veces ese codigo pero no doy con el problema, si alguien pudiera ayudarme sería un gran placer.
{
"id": 1
"name": "example",
"surname": "example",
"email": "example",
"phone": "example",
"image": "example",
"description": "example",
"social_network": "example,
"products", [
{
"id": 0,
"name": "example",
"subtitle": "example",
"category": "example",
"height": "example",
"release_time": "example",
"ship": "example",
"description": "example",
"images": [
"id": 0,
"alt": "example",
"url": "example",
"extension": "example",
"status": 0,
"date": "example"
],
"price": 0,
"status": 0,
"date", "example"
}
],
"status": 0,
"date": "example"
}
Si alguien pudiera ayudarme se lo agradeceria muchisimo, no entiendo por que el error que sale al intentar ejecutar esa consulta ** ERROR 1111 (HY000): Invalid use of group function **