开发者

sybase sql update where record equal to another record

开发者 https://www.devze.com 2023-01-28 22:48 出处:网络
I have a table that looks like the following: userId | level| ------------------- snoop| 10| foo| 0|

I have a table that looks like the following:

| userId | level  |
-------------------
| snoop  | 10     |
| foo    | 0      |
| bar    | 0      |

I would like to update the level of all the users to whatever the level of snoop is.

I know that I开发者_开发技巧 could get the value and go: update table set level = 10

but if I didn't want to hardcode the value 10 and needed to do this in one query, how would I do it?

Thanks!


update table
    set level = (select level from table where userId = 'snoop')
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号