如何将值插入我刚刚选择的值?

时间:2011-06-28 12:48:29

标签: c# asp.net sql

sb.Append("SELECT u.Reputation");
sb.Append(" FROM Users AS u");
sb.Append(" INNER JOIN Comments AS c ON c.UsersID=u.UsersID");
sb.Append(" WHERE c.CommentsID=@CommentsID");

我想从users表中选择那个值..Reputation,然后将数字5插入它..我该怎么做..?我希望用户信誉在数据库中的值为5。

1 个答案:

答案 0 :(得分:3)

UPDATE Users u 
SET u.Reputation = (u.Reputation + 5) 
INNER JOIN Comments AS c ON c.UsersID=u.UsersID 
WHERE c.CommentsID=@CommentsID