If we have multiple conditions to check, can we use like operator?
eg where empid like ('123%') or like ('23%')?
Printable View
If we have multiple conditions to check, can we use like operator?
eg where empid like ('123%') or like ('23%')?
The LIKE operator is used in character string comparisons with
pattern matching.
If empid is defined as varchar Then
select * from emp where empid like '123%'
retrieve records of emp where empid starts with 123
select * from emp where empid like '23%'
retrieve records of emp where empid starts with 23
Like operator is used to retrieve records starting with the alphabet or numeric specified as the condition. For example,
<b>Select * from emp where emp_name like 'Joh%'</b>
This statement will retrieve the records where the employee name starts with "Joh"
LIKE operator is used for pattern matching you can combine multiple statments for different conditions using logical operators.
u can combine like operator in multiple condition
for eg. where (name like 'abc%' or name like 'pqr%');
I have a table like employee containing name column.
In name it contains:- SMITH,MARTIN,MILLER,ADAMS etc.
I want a result from name whose first character is 'M', Second character can be any, But third character should not be 'R'.
select name from employee where name like 'M_[^R]%' is fetching 0 results.
Please suggest a query for oracle server.
You need to use [URL="http://docs.oracle.com/cd/B12037_01/server.101/b10759/conditions018.htm#SQLRF00501"]REGEXP_LIKE[/URL] for the purpose.