【发布时间】:2018-09-06 21:25:01
【问题描述】:
我使用 sqlite 并且有一个看起来像这样的表:
我正在尝试使用 col2 对应 col1 的值更新引用列
我试过像
这样的查询update tab1
set refer = (select col2 from tab1 where col1 = refer)
where col1 = 2
这但不起作用。
我也试过了
update tab1
set refer = (select tem1.col2
from tab1 tem1, tab1 tem2
where tem1.col1 = tem2.refer and tem2.col1=2)
where col1 = 2
这行得通。
但我不确定这是否是正确的做法。
【问题讨论】:
-
您实际使用的是哪些 dbms? (删除未涉及产品的标签。)
-
这里的大多数人想要格式化文本,而不是图像(或图像链接)。
-
请发布预期结果
-
哪个数据库正在使用??
标签: mysql sql sql-server sqlite