2010-12-05 39 views
0

我需要更新基于这两个用户的表。单个查询更新根据ID

为例如:

update table1 set [email protected] where [email protected]/[email protected] 

所以我需要写满足条件为两个用户 user1和user2单个查询。

如果我传递@userid,如果它匹配用户的id,它应该更新user1记录。如果我传递的id是user2的id,那么它应该更新user2 rec。

如何检查在单个查询这个条件.......

任何想法????????

+1

你能后的基本表结构?我想我们可能会错过一些东西。 – 2010-12-05 13:09:17

回答

0

我不完全理解你的要求 - 假设你有两个ID的,user1user2一个表,要更新该行的时候@userId比赛两者中任选一种,你可以使用:

update table1 
set rating = @rate 
where (user1 = @userid or user2 = @userid) 

这是你在找什么?或者我误解了你的问题?如果是这样:请澄清!也许向我们展示你的表格结构或者什么来帮助我们理解。