[英]Multiply a Value from one table with all rows of a field on the second table
I have two tables.我有两张桌子。 I want to multiply a single factor value from the currency table with all the rows of the Price field from the Product table.
我想将货币表中的单个因子值与产品表中价格字段的所有行相乘。
Select Product.ID, (Product.Price* (select factor from Currency)) as NewPrice,
Product.weight, Product.description
from Product,
Currency
It does not seem to work.它似乎不起作用。 Please suggest the correct statement.
请提出正确的说法。
It should be something like this (except the currency id on which you join the tables):它应该是这样的(除了你加入表格的货币 ID):
Select P.ID
,P.Price*C.factor as NewPrice
,P.weight
,P.description
from Product P
INNER JOIN Currency C
ON P.[currencyID] = C.[currencyID]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.