How to repeat row based on qty field
You need a table of numbers, and fill this table with sequential number as much as you want.

CREATE TABLE numbers (
    number int
)
ENGINE = InnoDB;

INSERT INTO numbers (number) VALUES (1), (2), (3), (4), (5); -- you can add more number according your needs.


And then join this table with your table.

SELECT p.id, p.product, 1
FROM products p
     JOIN numbers n ON p.qty &gt;= n.number;


This should produce result as you want.

If you can't create table, you can simulate table with UNION.

SELECT p.id, p.product, 1
FROM products p
    JOIN (
                SELECT 1 as number UNION
                SELECT 2 UNION
                SELECT 3 -- you can continue this line
               ) n
    ON p.qty &gt;= n.number;