Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
elaine
Starting Member
6 Posts |
Posted - 2012-01-19 : 17:13:37
|
Hi everyone,Currently I have one problem for, dealing with excel table. I want to import the table into the My SQL Database and join it with other table. Currently, for 1st table, I need to extract the id and product columns, then join with other tables by product.The problem is: Some id corresponds to multiple products, which makes me hard to join by matching product with tables.Now I want to modify the 1st table to make sure one id correspond to one product in one rows. So that id 1 product: A;B;C in one row becomes:id 1 product: A id 1 product B id 1 product C in three rows.I know it may need loops to realize this, but can not make it work by myself. Does anyone can help me? |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
elaine
Starting Member
6 Posts |
Posted - 2012-01-22 : 11:41:06
|
Hi Tara,Thanks a lot for your reply. I did see how to update a file in the forum...So the data sample is as follows:original data the final data table needed id product id product1 A 1 A2 A;B;C 2 A3 D;B 2 B4 C;F 2 C5 B 3 D6 D;E;J 3 B7 M 4 C8 G;H;O 4 F9 I;Q;P 5 B10 N 6 D11 G;H;O 6 E12 H 6 J13 R 7 M14 I;T;O 8 G15 P;J;K 8 H16 E 8 O17 I;M;L 9 I18 Q 9 Q19 A;J;P 9 P20 E;U;K 10 N21 P;H;I 11 G 11 H 11 O 12 H 13 R 14 I 14 T 14 O 15 P 15 J 15 K 16 E 17 I 17 M 17 L 18 Q 19 A 19 J 19 P 20 E 20 U 20 K 21 P 21 H 21 I |
|
|
|
|
|