去看更多

wangshijie
Welcome

Sql 更新所有满足条件记录里第一条记录

我的办法是选出第一条记录Select top 1,然后选取表中其它几个列名,这几个字段的值决定该条记录是唯一的。

通过这些字段来更新对应行的记录。

update pub_p_templated set id =id+ " + i + " where (templateid=   ( select top 1 templateid from pub_p_templated where id=1) and itemid =(select top 1 itemid from pub_p_templated where id=1 ))"

这里选的字段是templateid和itemid

 

如果你有更好的办法就请教一下。

posted @ 2009-05-05 18:27  jeer  阅读(5941)  评论(4)    收藏  举报