update pos
set a = concat_ws((select b from (select * from pos where a is not null limit 1) as ta), '', b)
where a is null
我要更新every row
在专栏 a
来自last value
的b
其值为b
.
最佳答案
如果我理解正确,并且您正在使用 SQL Server,那么您正在寻找 LAG()
函数来获取 B
的先前值。弄清楚如何使用它。
https://msdn.microsoft.com/en-us/library/hh231256.aspx
Accesses data from a previous row in the same result set without the use of a self-join in SQL Server 2012. LAG provides access to a row at a given physical offset that comes before the current row. Use this analytic function in a SELECT statement to compare values in the current row with values in a previous row.
关于mysql - 如何从同一表中的另一列和行动态更新sql中的列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30045971/