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 |
|
allan8964
Posting Yak Master
249 Posts |
Posted - 2011-11-21 : 21:48:04
|
| Hi there,Scenario like this:table1 has column of ProdCode with rows about 20ABCCVBPLK...table2 has same column with qbout 30 rows as:ABCYPLPLK...I tried to copy all the ProdCode from 2 tables, both same and not the same to a new tabel3 make it looks as: (dash line means white space)ProdCode_1---------------ProdCode2ABC----------------------ABCCVB---------------------- PLK----------------------PLK...How can the code be? Thanks. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-11-21 : 22:02:12
|
[code]SELECT *FROM table1 t1 LEFT JOIN table2 t2 ON t1.col = t2.col[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
jassi.singh
Posting Yak Master
122 Posts |
Posted - 2011-11-22 : 03:08:04
|
| Do left join so that you will get data as requiredlikeProdCode_1--------------ProdCode2ABC----------------------ABCCVB---------------------- insert into tabel3(prodcode1,prodcode2)SELECT t1.prodcode1,t2.prodcode2FROM table1 t1 LEFT JOIN table2 t2 ON t1.col = t2.col |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-22 : 03:12:34
|
quote: Originally posted by jassi.singh Do left join so that you will get data as requiredlikeProdCode_1--------------ProdCode2ABC----------------------ABCCVB---------------------- insert into tabel3(prodcode1,prodcode2)SELECT t1.prodcode1,t2.prodcode2FROM table1 t1 LEFT JOIN table2 t2 ON t1.col = t2.col
whats the use of copy pasting same suggestion like this?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|