Thursday, 11 October 2012

Use Of LIKE Operator In Oracle


Retrieve a list of DEPARTMENT_NAME values that end with the three letters
“ing” from the DEPARTMENTS table.
1. Start SQL*Plus and connect to the HR schema.
2. The SELECT clause is
SELECT DEPARTMENT_NAME
Limit the Rows Retrieved by a Query 125
3. The FROM clause is
FROM DEPARTMENTS
4. The WHERE clause must perform a comparison between the DEPARTMENT_
NAME column values and a pattern of characters beginning with zero or more
characters but ending with three specific characters, “ing.”
5. The operator enabling character pattern matching is the LIKE operator. The
pattern the DEPARTMENT_NAME column must conform to is '%ing'.
The percentage wildcard symbol indicates that zero or more characters may
precede the “ing” string of characters.
6. Thus, the WHERE clause is
WHERE DEPARTMENT_NAME LIKE '%ing'
7. Executing this statement returns the set of results matching this pattern as
shown in the following illustration:

No comments:

Post a Comment