I am new to sql and right now I learn joins. the problem is in my table cars_equipment it shows my 4 times the same name. why ?
SELECT
c.id,
c.model,
c.description,
c.environment,
c.equipment,
c.ps,
c.tuv,
c.cover,
c.brand,
c.price,
c.engine,
c.fuel,
c.firstregistration,
c.km,
c.color,
c.video,
c.type,
c.show,
c.sit_place,
array_agg(ci.image) as images,
array_agg(ce.name) as equipments
FROM cars c
LEFT JOIN cars_images ci
ON ci.car_id = c.id
LEFT JOIN cars_equipment ce
ON ce.car_id = c.id
WHERE c.show IS TRUE AND c.id = $1
GROUP BY c.id, ce.id
LIMIT 1;
what I am doing wrong ?
if I remove group by ce.id then it shows my 20x null values and 4x times the same value