日期:2014-05-17  浏览次数:20450 次

求个sql语句,达人来~~
涉及2个表的查询更新问题。

表一 L_product  表二 L_price

L_product 表中字段
id,sprice,class    (id为自动编号,sprice为产品定价 class为产品分类)

L_price 表中字段 
id,product_id,price    (id为自动编号  product_id为L_product 表中id字段, price为折扣价格)

现在要求更新某个产品分类 class=1 下的商品的折扣价格,目前L_price中price价格为产品定价原价,即折扣100%,现在想更新L_price表中折扣价格为产品定价的95折。 

求sql语句,谢谢。






------解决方案--------------------
谢谢提醒
UPDATE  L_price
SET     L_price.price = L_product.sprice * 0.95
FROM    L_price
        INNER JOIN L_product ON L_product.id = L_price.L_product
WHERE   L_product.class = 1