SELECT | ENAME |
FROM | EMP |
WHERE | ENAME LIKE '%A%' |
The LIKE operator is used in the WHERE clause. The LIKE operator is used in the WHERE clause to perform pattern matching between the column name and the comparison string by specifying [Column name LIKE Comparison string].
The following two wildcards can be used in the comparison string
%(percent) | Any string of 0 or more characters |
_(underbar) | Any one character |
If you want to use % or _ itself as a search string, use the ESCAPE keyword. The following is written and the ESCAPE keyword is used to specify ? but the ? _ is treated as a mere _(A underscore), which is not a wildcard.
WHERE ENAME LIKE '%?_%' ESCAPE '?'
To negate the LIKE operator, use NOT before the LIKE operator, as in [Column name LIKE comparison string].
WHERE ENAME NOT LIKE '%A%'
Now for the exercise, I will give you one Question.
EmpNo | fullname | sectcode | extel |
S02 | Tanaka sanro | K001 | 1001 |
S05 | Sato kosan | K003 | 1003 |
S15 | Morisan keiko | K022 | 3022 |
S20 | Suzuki sanro | K105 | 1105 |
A | fullname = 'san' |
B | fullname = '%san%' |
C | fullname LIKE '%san%' |
D | fullname NOT LIKE '%san%' |
This completes the [Pattern search (LIKE)].