我有像'keepme:cutme'或'string-without-separator'这样的字符串,它们应分别成为'keepme'和'string-without-separator'.这可以在PostgreSQL中完成吗?我试过了:
select substring('first:last' from '.+:')
Run Code Online (Sandbox Code Playgroud)
但:如果:字符串中没有,则会离开,并且将无法工作.
如果我有一个字符串,如:
one\two\three\four\five\six\
two\three\four\five\six\one\
three\four\five\six\one\two\
four
five\six
Run Code Online (Sandbox Code Playgroud)
我该如何修剪它以便我最终得到它
one
two
three
four
five
Run Code Online (Sandbox Code Playgroud)
我试过了
LEFT(column_name_goes_here, CHARINDEX('\', column_name_goes_here) - 1)
Run Code Online (Sandbox Code Playgroud)
根据SQL Server替换的答案,删除所有特定字符后的所有内容
但它给了我以下错误消息:
Msg 537, Level 16, State 3, Procedure stored_procedure_one, Line 107
Invalid length parameter passed to the LEFT or SUBSTRING function.
Run Code Online (Sandbox Code Playgroud)