Oracle Like Operator





LIKE Operator

Like Operator is used to do wildcard search of valid string values.
Search can contain number or characters as well.

%   Denotes Zero or Many characters.
_    Denotes Single character.

For Eg. 

1) Display all employees who's first_name starts with a upper case 'K'.

SELECT employee_id,first_name FROM employees WHERE first_name LIKE 'K%';










2) Display all employees who's first name's 2nd character is 'h' and contains zero or more characters after that.

SELECT employee_id,first_name FROM employees WHERE first_name LIKE '_h%';








Escape Option

Cases where we want an actual match for % and _ characters use the ESCAPE option.

For eg.
To Display all employees where job id contains SA_ we can use the below query.

SELECT employee_id,first_name,job_id FROM employees WHERE job_id LIKE '%SA\_%' ESCAPE '\';



















Previous Page                                                                                                              Next Page