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 |
webmaster@aklan.net
Starting Member
2 Posts |
Posted - 2007-02-15 : 13:03:01
|
Hi, I have a table called temp_dump with columns area1, area2, area3 and have a lookup table called area that has the IDs of area1, area2 and area3.Now, can u help me compose a sql statement that will get an areaid of area1, area2 and area3 and insert INTO a new table?Thank you, |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-02-15 : 13:19:32
|
select t1.someothercolumn, t2.somecolumn, t3.ausefulcolumninto NewTableNameHerefrom temp_dump as tleft join lookuptable1 as t1 on t1.fkcol = t.pkcolleft join lookuptable1 as t2 on t2.fkcol = t.pkcolleft join lookuptable1 as t3 on t3.fkcol = t.pkcolPeter LarssonHelsingborg, Sweden |
 |
|
webmaster@aklan.net
Starting Member
2 Posts |
Posted - 2007-02-15 : 13:46:17
|
Thanks Dude,It's working!quote: Originally posted by Peso select t1.someothercolumn, t2.somecolumn, t3.ausefulcolumninto NewTableNameHerefrom temp_dump as tleft join lookuptable1 as t1 on t1.fkcol = t.pkcolleft join lookuptable1 as t2 on t2.fkcol = t.pkcolleft join lookuptable1 as t3 on t3.fkcol = t.pkcolPeter LarssonHelsingborg, Sweden
|
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-02-15 : 14:44:43
|
Did you write something like this?select t1.areaname, t2.areaname, t3.areanameinto NewTableNameHerefrom temp_dump as tleft join area as t1 on t1.id = t.area1left join area as t2 on t2.id = t.area2left join area as t3 on t3.id = t.area3 Peter LarssonHelsingborg, Sweden |
 |
|
|
|
|
|
|