I have a table in MySQL that contains products ordered in an online store. I would like to generate a list of every ordered item, so I need to return multiple copies of a row based on the quantity of the item ordered:
+------------------+-------------+------------+-------+----------+
| order_product_id | order_id | product_id | model | quantity |
+------------------+-------------+------------+-------+----------+
| 2254 | 1427 | 56 | B-WO | 2 |
| 2253 | 1426 | 56 | B-WO | 2 |
| 2252 | 1425 | 56 | B-WO | 1 |
| 2251 | 1425 | 51 | 11 | 1 |
+------------------+-------------+------------+-------+----------+
Desired output, optionally including a counter for the item number out of the total:
+------------------+-------------+------------+-------+----------+------------------------+
| order_product_id | order_id | product_id | model | quantity | item number (optional) |
+------------------+-------------+------------+-------+----------+------------------------+
| 2254 | 1427 | 56 | B-WO | 2 | 1 |
| 2254 | 1427 | 56 | B-WO | 2 | 2 |
| 2253 | 1426 | 56 | B-WO | 2 | 1 |
| 2253 | 1426 | 56 | B-WO | 2 | 2 |
| 2252 | 1425 | 56 | B-WO | 1 | 1 |
| 2251 | 1425 | 51 | 11 | 1 | 1 |
+------------------+-------------+------------+-------+----------+------------------------+
Is there a straightforward MySQL way to do this?