【问题标题】:sybase sql update where record equal to another recordsybase sql更新其中记录等于另一条记录
【发布时间】:2010-12-06 19:23:09
【问题描述】:

我有一个如下所示的表格:

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

我想将所有用户的级别更新为窥探级别。

我知道我可以得到价值然后去: update table set level = 10

但如果我不想硬编码值 10 并且需要在一个查询中执行此操作,我该怎么做?

谢谢!

【问题讨论】:

    标签: sql sybase


    【解决方案1】:
    update table
        set level = (select level from table where userId = 'snoop')
    

    【讨论】:

      猜你喜欢
      • 2014-09-01
      • 1970-01-01
      • 2019-02-18
      • 2013-11-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-20
      相关资源
      最近更新 更多