【发布时间】:2020-07-03 12:49:39
【问题描述】:
我是 postgresql 新手,需要更新脚本方面的帮助,如果没有,我可以在 path2 和文件名之间插入相应的 ID。这将在多条记录上完成。
table1
id name path
111 Test1 /path1/path2/file1.png
222 Test1 /path1/path2/222/file2.png
333 Test3 /path1/path2/file3.png
444 Test3 https:test/path1/path2/file4.png
555 Test4 /path1/path2/file5.png
更新后,只有 ID 111 和 333 会受到影响,预计为 /path1/path2/111/file1.png /path1/path2/333/file3.png
我正在使用这个选择来获取需要更新的记录。
select * from table1
where name in ('Test1','Test3')
and path like '/path1/path2/%'
and path not like '/path1/path2/%/%'
【问题讨论】:
标签: sql postgresql sql-update