SELECT ROW_NUMBER() OVER(ORDER BY b.id) labelNum, i.name, i.`size`, i.category, ink.id color, o.code origin, b.packing, b.`grouping`, i.stems, b.id, p.name producer FROM buy b JOIN item i ON i.id = b.itemFk LEFT JOIN producer p ON p.id = i.producerFk LEFT JOIN ink ON ink.id = i.inkFk LEFT JOIN origin o ON o.id = i.originFk WHERE b.entryFk = ?