Saya pikir, lebih baik untuk menyelesaikan bukan dengan query(SQL). Ada beberapa fitur generasi, tetapi kinerjanya buruk.
Anda harus mengubah model Anda (simpan selalu 1 kuantitas), atau proses di backend (java/c/stb.)
Select id,
1 as quantity,
price_charged
from table_name t
JOIN
(SELECT e*10000+d*1000+c*100+b*10+a n FROM
(select 0 a union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t1,
(select 0 b union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t2,
(select 0 c union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t3,
(select 0 d union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t4,
(select 0 e union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t5) counter
ON (counter.n<=t.quantity)
Subquery yang bergabung mengulangi nomor dari 0 hingga 99999, ini adalah jumlah maksimum yang dibakar. Penggabungan diulangi oleh penghitung 0... nilai kuantitas-1.