What is the CHARINDEX (SQL SERVER) equivalent in P

2020-03-08 08:45发布

I am trying CHARINDEX in Postgresql. But it says:

function CHARINDEX() does not exist

If no such inbuilt function exists in postgresql, then is there any function that serves as an alternative to charindex?
If yes, What is the CHARINDEX (SQL SERVER) equivalent in POSTGRESQL ?

1条回答
该账号已被封号
2楼-- · 2020-03-08 09:18

The equivalent function in postgresql is:

strpos(string, substring)

Or:

position(substring in string)

They are equivalent, just with different order in parameters.
If you also need parameter start_location, you will need to pass a substring to strpos.

You can find them in: https://www.postgresql.org/docs/current/functions-string.html

查看更多
登录 后发表回答