Comparison of the corresponding function Instr in SQL and Oracle
- 2021-09-16 08:28:19
- OfStack
sql: charindex ('string ', field)
>
0 charindex('administrator',MUserID)
>
0
oracle: instr (Field, 'String', 1, 1) > 0 instr(MUserID,'administrator',1,1) > 0
In the project used Oracle in Instr this function, by the way carefully again to learn 1 this knowledge.
In Oracle, you can use the Instr function to judge whether a string contains specified characters.
Its syntax is:
Instr(string, substring, position, occurrence)
Among them
string: Represents the source string;
substring: Represents the substring you want to find in the source string;
position: Represents the starting position of the lookup. This parameter is optional and defaults to 1;
occurrence: Represents the number of occurrences of substring that you want to find from the source character. This parameter is also optional and defaults to 1;
If the value of position is negative, it means looking from right to left.
The return value is: the position of the found string.
For the Instr function, we often use this to find the position of a specified substring from a string.
For example:
The display result of SELECT Instr ('Hello Word', 'o',-1, 1) "String" FROM Dual is
Instring
---
8
oracle: instr (Field, 'String', 1, 1) > 0 instr(MUserID,'administrator',1,1) > 0
In the project used Oracle in Instr this function, by the way carefully again to learn 1 this knowledge.
In Oracle, you can use the Instr function to judge whether a string contains specified characters.
Its syntax is:
Instr(string, substring, position, occurrence)
Among them
string: Represents the source string;
substring: Represents the substring you want to find in the source string;
position: Represents the starting position of the lookup. This parameter is optional and defaults to 1;
occurrence: Represents the number of occurrences of substring that you want to find from the source character. This parameter is also optional and defaults to 1;
If the value of position is negative, it means looking from right to left.
The return value is: the position of the found string.
For the Instr function, we often use this to find the position of a specified substring from a string.
For example:
The display result of SELECT Instr ('Hello Word', 'o',-1, 1) "String" FROM Dual is
Instring
---
8