I have a product table in MySQL, which stores the barcode and the stock quantity of a product.
What I need is to generate an SQL query so that the rows can be repeated with certain information of a single product depending on the amount that it has in Stock.
They would be fictitious rows. For example, if I have 35 products in stock, the query should return me 35 times the bar code of the product as a result.
The product table has the following structure:
id_prod codbar_prod des_prod pre_com stock_act
1 27478255368371 ASDFADSFADFS 50000 10
2 27478255368372 ASDESCRIPCION 150000 116
If for example I need to know the barcode of the product 1. I would make a query in the following way:
SELECT codbar_prod FROM productos WHERE id_prod=1;
Return the following:
codbar_prod
--------------
27478255368371
This way it works, but what I would need is that said query result is repeated taking into account the quantity in stock in this case; would be for example a result similar to the following:
codbar_prod
--------------
27478255368371
27478255368371
27478255368371
27478255368371
27478255368371
27478255368371
27478255368371
27478255368371
27478255368371
27478255368371