如何在SQL Server 2008中使用另一个表列来表述表值 [英] how to formulate a table value with another tables column in sql server 2008
问题描述
0
我有两个桌子
库存表和订单项目表
库存表包含一个Sold_Stock字段
订单项目表包含一个数量字段
两个表都通过Item_ID(库存表中的主键和订单项表中的外键)链接.
我想知道如何在SQL Server 2008中在Sold_Stock字段上编写公式,以便每当将一条记录插入到Order Items Table中时,数量字段值就会被添加到Stock Table中的Sold_Stock字段中.
我知道如何在一个表中编写公式,但是我不知道引用另一个表的列.谁能帮帮我!
在此先感谢
Mirfath
0
Hi,
I have two tables
Stock table and Order Items Table
The Stock Table contains a Sold_Stock field
The Order Items Table contains a quantity field
both tables are linked by an Item_ID (Primary key in the Stock Table and Foreign key in the Order Items Table)
I want to know how to write a formula in Sql Server 2008 on the Sold_Stock field so that whenever a record is inserted into the Order Items Table the quantity field value will get added to the Sold_Stock field in the Stock Table.
I know how to write formulas within a table but i have no idea to reference another table''s column. Can anyone please help me out!
Thanks in advance
Mirfath
推荐答案
触发最适合此问题
这篇关于如何在SQL Server 2008中使用另一个表列来表述表值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!