表结构
PriceTypeid varchar(25)
Ptypeid varchar(25)
Price numeric(13)
表如下
pricetypeid ptypeid price
LSSJ1 0001 0
YSSJ1 0001 10
现在要把YSSJ1 对应的PRICE 复制到LSSJ1
这个语句应该怎么写呢。
谢谢各位朋友
PriceTypeid varchar(25)
Ptypeid varchar(25)
Price numeric(13)
表如下
pricetypeid ptypeid price
LSSJ1 0001 0
YSSJ1 0001 10
现在要把YSSJ1 对应的PRICE 复制到LSSJ1
这个语句应该怎么写呢。
谢谢各位朋友
LSSJ10 0001 0
YSSJ110 0001 10
LSSJ1 0001 10
YSSJ1 0001 10
ptypeid下面还有其它商品
pricetypeid ptypeid price
LSSJ1 0001 0
YSSJ1 0001 10
LSSJ1 0002 20
YSSJ1 0002 10
update 表 set price=B.price
from 表 A,
(select * from A where pricetypeid='YSSJ1') B
where A.pricetypeid='LSSJ1'
and A.ptypeid =B.ptypeid
from 表 A,
(select * from A where pricetypeid='YSSJ1') B
where A.pricetypeid='LSSJ1'
and A.ptypeid =B.ptypeid
and A.ptypeid ='0001'
LSSJ1 0001 0
YSSJ1 0001 10
现在要把YSSJ1 对应的PRICE 复制到LSSJ1
这个语句应该怎么写呢。
------------------------
update t
set price=b.price
from t a left join(select * from t where pricetypeid ='YSSJ1') b
on a.ptypeid=b.ptypeid
where a.pricetypeid='LSSJ1'