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
谢谢分解了
...全文
1192打赏收藏
意思是什么了
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 谢谢分解了
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 的前三条记录
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(),即当前时间