Oracle uses the instr or like method to determine whether the string is contained. oracleinstr
The first thought is contains. The usage of contains is as follows:
select * from students where contains(address, 'beijing')
However, a condition for using the ins predicate is that the column must be indexed. That is to say, if the address column of the students table in the preceding statement is not indexed, an error is returned.
Fortunately, there is another way to use instr. The usage of instr is as follows:
select * from students where instr(address, 'beijing') > 0
In addition, there is a stupid way, that is, to use like. Here we should know how to do it:
select * from students where address like '%beijing%'
Oracle determines whether the character is in the string
INSTR (C1, C2, I, J)
Searches for a specified character in a string and returns the location where the specified character is found;
String searched by C1
String to be searched by C2
The start position of the I search. The default value is 1.
Where J appears. The default value is 1.
SQL> select instr ('oracle traning', 'A', 1, 2) instring from dual; INSTRING
---------
9. You can determine if instr ('123', lx, 1356)> 0 then ...... else ...... end if;
In oracle, how does one determine whether a character exists in a string?
Declare aa varchar2: = 'wkressdfdf ';
Begin
If instr (aa,'s ')> 0 then
Dbms_output.put_line ('s character ');
Else
Dbms_output.put_line ('no s character ');
End if;
End;