Reputation: 917
i have table in the following format
**id mobile landline**
x1 2,3,4 17,18
x2 4,5,6
x3 7,8,9 19
trying to insert the data in a table in the following table.
**id mobile landline**
x1 2 17
x1 3 18
x1 4
Please help.
Upvotes: 1
Views: 673
Reputation: 1088
Is the end table structure negotiable? Might I propose:
id type value
x1 mobile 2
x1 mobile 3
x1 mobile 4
x1 landline 17
x1 landline 18
or if you have to go with columns for landline and mobile:
id mobile landline**
x1 2 <null>
x1 3 <null>
x1 4 <null>
x1 <null> 17
x1 <null> 18
Otherwise it appears that landline 17 is associated with mobile 2, which isn't implied in the source table.
Once you've decided that, check out Split comma separated value from table column into rows using mysql? and see if you can apply that solution.
Upvotes: 1