简体   繁体   中英

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):

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM