我需要更新一个SQLite表。
该表如下所示:
ID | Address | CallNumber | RefID -----+--------------------+------------------------------------------- ef78 | library | 2002/13 | 100002 no56 | Lit | 0189 | 100003 rs90 | temp | | 100003
对于Address = "Lit“的每一列,都有一个具有相同RefID的Address = 'temp‘列。现在,我需要用具有相同RefID的列中的值"CallNumber“更新每个Address = "temp”。
更新后的表应如下所示:
ID | Address | CallNumber | RefID -----+--------------------+------------------------------------------- ef78 | library | 2002/13 | 100002 no56 | Lit | 0189 | 100003 rs90 | 0189 | | 100003
我试过这个:
UPDATE Location SET address = foo.callnumber FROM (select RefID, CallNumber FROM Location) foo