意思是什么了

huangwei_d107 2005-09-28 10:24:01
update tbclinfo set fddtime = getdate() from (select top 3 * from tbclinfo where fdcneirong like '%'+ @messagetemp+'%' order by fddtime ) AS t1 WHERE tbclinfo.fdiid = t1.fdiid

谢谢分解了
...全文
119 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
iwl 2005-09-28
  • 打赏
  • 举报
回复
update tbclinfo set fddtime = getdate() from (select top 3 * from tbclinfo where fdcneirong like '%'+ @messagetemp+'%' order by fddtime ) AS t1 WHERE tbclinfo.fdiid = t1.fdiid

首先:是子查询 select top 3 * from tbclinfo where fdcneirong like '%'+ @messagetemp+'%' order by fddtime 表示从表tbclinfo里面找到 列fdcneirong内容包含 @messagetemp 的前三条记录

然后:修改表tbclinfo中的fddtime等于当天的日期。修改条件是表tbclinfo.fdiid和子查询的结果集T1.tbclinfo相等。

MorningTea 2005-09-28
  • 打赏
  • 举报
回复
是不是漏掉了什么?!

update tbclinfo
set fddtime = getdate()
from tbclinfo,--这种格式应该加上要更新的表
(select top 3 * from tbclinfo where fdcneirong like '%'+ @messagetemp+'%' order by fddtime ) AS t1
WHERE tbclinfo.fdiid = t1.fdiid
--其实就是更新符合fdcneirong like '%'+ @messagetemp+'%' 条件的纪录,按照fddtime降序排列的前三条的fddtime为GETDATE(),即当前时间

34,587

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧