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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Update one table from other table

Author  Topic 

joriveek
Starting Member

33 Posts

Posted - 2006-04-12 : 04:16:20

Hi,

I have two tables, I want to make update operation.

Table1:

Description|Quantity| Rate
---------------------------
Item 1 30 100
Item 2 40 200
Item 1 20 300
---------------------------

Table2:
Description|Quantity| Rate
---------------------------
Item 1 -10 100
Item 2 -15 200
Item 1 -5 300
----------------------------

I want UPDATE should be performed on Table1.Quantity = Table1.Quantity + Table2.Quantity on the all the columns have matches for descriptions in Table 1 that exists in Table2

Example:

Update Table1 Set Quantity = Quantity + (select Quantity From Table2
where Table2.Quantity = Table1.Quantity)....something like this????

Any help please? This is just performing update on table1 by matching DESCRIPTION field between two tables..

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-04-12 : 04:45:00
Somthing like this

Update Table1 Set Quantity = Quantity + Table2.Quanitity From Table2 Where
Quantity = Table2.Quantity???


If Debugging is the process of removing Bugs then i Guess programming should be process of Adding them.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-04-12 : 04:58:18
Update T1 Set Quantity = Quantity + T2.Quanitity From Table1 T1 inner join Table2 T2 on
T1.Description= T2.Description


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -