POSTGRESQL中的CHARINDEX(SQL SERVER)等效项是什么? [英] What is the CHARINDEX (SQL SERVER) equivalent in POSTGRESQL?
问题描述
我正在Postgresql中尝试 CHARINDEX
。但是它说:
I am trying CHARINDEX
in Postgresql. But it says:
function CHARINDEX() does not exist
如果postgresql中不存在这样的内置函数,那么是否有任何函数可以替代charindex?
如果是,那么POSTGRESQL中 CHARINDEX
(SQL SERVER)的等效项是什么?
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 ?
推荐答案
postgresql中的等效函数为:
The equivalent function in postgresql is:
strpos(string, substring)
或:
position(substring in string)
它们是等效的,只是参数的顺序不同。
如果还需要参数start_location,则需要将子字符串传递给strpos。
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.
您可以在以下位置找到它们: https://www.postgresql.org/docs/current/functions-string.html
You can find them in: https://www.postgresql.org/docs/current/functions-string.html
这篇关于POSTGRESQL中的CHARINDEX(SQL SERVER)等效项是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!