Update statement syntax

General

Update statement syntax

Hi,

I have 2 tables, the main table & the second table.

The 'main table' has an Acct_Num field & a 'placeholder' column called 'item_1' & containing a zero.

The second table contains an Acct_Num & an item_1 field - the item_1 contains counts of items per Acct_Num. 

I want to Update the 'main table' 'item_1' field with the count of 'item_1's contained in the second table.

I tried to use the below Update statement to do this but it seems to just remove the zero that was on the 'main table' & leave it blank instead of adding the existing number value from the second table.

Can anyone advise where I'm going wrong?

Thanks

UPDATE my_table 

FROM second_table s

SET item_1 = S.item_1

WHERE my_table.Accnt_Num = S.Accnt_Num
1 REPLY

Re: Update statement syntax

Hi, I found that the tables had different data types and that was the problem!!

Changed one table to suit the other & all worked.