|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
help on sql update!
Hi friends,
I’d like to update Column code in Table1 with the code value in Table 2, the criteria is the same zip. Below are the whole table and my code. However, I get the error message:” Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.”. Could you please give me a hand? Thanks a lot. Table1 Table2 Name Zip code Zip Code A 95035 Null 95035 11 B 95035 Null 95036 11 C 95036 Null 95037 12 D 95037 Null E 95038 Null UPDATE Table1 SET code=(SELECT Table2.code from Table1, Table2 WHERE Table1.zip = Table2.zip) |
|
#2
|
||||
|
||||
|
Code:
update Table1
set Code = t2.Code
from Table1 t1
inner
join Table2 t2
on t1.Zip = t2.Zip
|
|
#3
|
|||
|
|||
|
It works.
Quote:
Thank you so much! |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > help on sql update! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|