I have old table which the data stored as
tbl_id tbl_data
--------------------
1 1,2,3,4,5,6
2 3,4,5
Now I want convert these to many-to-many relationship table.
user_id user_option
-------------------
1 1
1 2
1 3
...
Basically I insert the data in php
$old = explode(",", $data['tbl_data']);
$query = $db->query("SELECT tbl_id, tbl_data FROM old_table");
while($fetch = $db->fetch($query)) {
$db->query("INSERT INTO new_table SET .....");
}
May I know, there have a way to get this done with single MySQL statement?