0

hello everyone..I would be grateful if anybody could help me in performing subtraction from diffrent tables...
My Database has a Asset table which has opening balance and balance left coloums in it.and i have one store table which has received/issued item and its quantity.Wat i want to do is if i select receive in a combo box and enter the quantity it should be deducted /added from the opening balance and remaining should be displayed in balance quantity.Plzzz help me its Urgent

3
Contributors
5
Replies
6
Views
8 Years
Discussion Span
Last Post by sknake
0

the quantity is not deducting from the quantity wat should i do to deduct the quantity??

0

Update statement:
You should send the ID and the Value be deduction from the existing quantity

Update Table 
Set Quantity = Quantity - @Value 
Where ID=@ID
0

Update statement:
You should send the ID and the Value be deduction from the existing quantity

Update Table 
Set Quantity = Quantity - @Value 
Where ID=@ID

i hv used this query bt its showing syntax error...can u help me with this
String query = "update Asset SET Unit= " +(asset.Unit-store.Quantity) + " where ItemCode = '" + asset.ItemCode;

0

This is the wrong forum, please post future SQL questions to the MSSQL forum (or respective rdbms).

Try a query like this:

Update Asset
Set Unit = Asset.Unit -
(
  Select Sum(Store.Quantity)
  From Store
  Where Store.ItemCode = Asset.ItemCode
)

The above query will work for a 1-to-1 or a 1-to-many relationship since you did not provide information on how the tables are joined.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.