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 |
senthil_red
Starting Member
1 Post |
Posted - 2007-09-18 : 04:38:51
|
Hi, i have one problem in query. i wnt to update one column in table by inserting another column of other table.1) create table table1 (col1 integer)2) insert into table1(col1) select col1 from table23) alter table table1 add col2 integer4) update table1 set col2 in (select col2 from table2 where table2.id=7) where table1.col2 is NULL In this subquery returns more than one value. i tried out this query but it shows error as incorrect syntax near keyword 'in' and incorrect syntax near keyword 'where'. My aim is to update table1.col2 in single update by inserting col2 from table2. How to do this? please help me.-senthil |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-09-18 : 04:55:04
|
This is your query as of now. It updates ALL records in table1 with the value from table2update t1set t1.col2 = t2.col2from table1 as t1inner join table2 as t2 on t2.id = 7where t1.col2 is null I think you needupdate t1set t1.col2 = t2.col2from table1 as t1inner join table2 as t2 on t2.id = t1.idwhere t1.col2 is nulland t2.col2 = 7 E 12°55'05.25"N 56°04'39.16" |
|
|
|
|
|