thanks for your answer but I don't know how to apply it very well to my case my table name is (tblregs) please consider that I tried to apply the solution but I didn't succeed.
the SQL code that I applied:
select
`Quan`,
SUBSTRING_INDEX(SUBSTRING_INDEX(LinkedIDs, ',', numbers.n), ',', -1) as name
from
numbers inner join tblregs
on CHAR_LENGTH(LinkedIDs)
-CHAR_LENGTH(REPLACE(LinkedIDs, ',', ''))>=numbers.n-1
order by
Quan, n
I have the following table:
+-------------+------+
| LinkedIDs | Quan |
+-------------+------+
| 150,151,152 | 50 |
+-------------+------+
| 200,250,270 | 35 |
+-------------+------+
| 151 | 80 |
+-------------+------+
| 260,152 | 90 |
+-------------+------+
what I tried to do is make it like the following table:
+-----------+------+
| LinkedIDs | Quan |
+-----------+------+
| 150 | 50 |
+-----------+------+
| 151 | 50 |
+-----------+------+
| 152 | 50 |
+-----------+------+
| 200 | 35 |
+-----------+------+
| 250 | 35 |
+-----------+------+
| 270 | 35 |
+-----------+------+
| 151 | 80 |
+-----------+------+
| 260 | 90 |
+-----------+------+
| 152 | 90 |
+-----------+------+
how to do that in MySQL?
note: the values in LinkedIDs can be 1 or more than one.