- Oracle allows facility to access records that matches specific pattern.
- It can be helpful when we don’t know the exact form of data that we want to search.
- Oracle uses “LIKE” predicate for pattern matching.
- LIKE predicate uses two symbols for pattern matching.
- _ ( Underscore)
- % ( Percentage)
- Underscore can be used for single character matching.
- Percentage sign can be used for multiple character matching.
SELECT * FROM <table name> WHERE <expression> LIKE <pattern>;
SELECT * FROM student WHERE std_name LIKE ‘_ameer’; SELECT * FROM student WHERE std_name LIKE ‘A%’;
- The 1st command will return name of the student containing ameer with preceding any of the single character (i.e Sameer,Aameer etc).
- The 2nd command will display student name starting from letter ‘A’.
- We can use percentage sign and underscore at any place for pattern matching.
- We can also use both symbols in combination.