且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将数据从同一表中的一行复制到另一行.

更新时间:2022-06-12 22:19:46

如果连接列为Name,则类似于:
If the connecting column is Name then something like:
UPDATE MyTable
SET Comm = (SELECT Fees 
            FROM MyTable mt2
            WHERE mt2.Name = MyTable.Name
            AND mt2.Id != MyTable.Id)


但是,如果您有两个以上的同名行,则失败,因此应扩展这种情况下的条件.


However that fails if you have more than 2 rows with the same name so the condition in that case should be expanded.