sybase sql update where record equal to another record
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')
精彩评论