首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

语句的写法

2012-01-30 
求一个语句的写法一张表A,样式如下:fIDfDate--------------------------------------0011900-01-010012003

求一个语句的写法
一张表A,样式如下:

fID                   fDate
--------------------------------------
001                   1900-01-01
001                   2003-05-04
002                   1900-01-01
002                   2007-03-04
002                   1900-01-01
...................


同一个fID号,把fDate为1900-01-01的更新为不是1900-01-01日期的

[解决办法]
update 表A
set fDate=(select top 1 fDate from 表A AS T1 where T1.fid=表A.Fid and fdate <> '1900-01-01 ' )
where fdate= '1900-01-01 '
[解决办法]

update m
set
fDate=n.fDate
from
表A m,
表A n
where
m.fID=n.fID and m.fDate= '1900-01-01 ' and n.fDate <> '1900-01-01 '

热点排行