我有一個表格,其中列location
中有文件的文件夾,例如, '/home/ubuntu/test'
和name
列中有文件名,例如'test1.png'
。連接兩列,並用postgresql中的結果替換其中一列
我想用完整路徑替換location
列,例如, '/home/ubuntu/test/test.png'
。
我嘗試這樣做:
UPDATE experiment_11.microscope_image_files
SET location=(SELECT concat_ws('/', location::text, name::text)
FROM experiment_11.microscope_image_files);
,但我得到了以下錯誤:
ERROR: more than one row returned by a subquery used as an expression
嘗試'UPDATE experiment_11.microscope_image_files SET位置= concat_ws('/',位置::文本,名稱::文本)' – barbsan