The PART_CODE column in the SPARES table contains the following list of values:
Which statement is true regarding the outcome of the above query?
A.
It produces an error.
B.
It displays all values.
C.
It displays only the values A%_WQ123 and AB_WQ123 .
D.
It displays only the values A%_WQ123 and A%BWQ123 .
E.
It displays only the values A%BWQ123 and AB_WQ123.
Explanation:
Combining Wildcard Characters
The % and _ symbols can be used in any combination with literal characters. The example in the
slide displays the names of all employees whose last names have the letter “o” as the second
character.
ESCAPE Identifier
When you need to have an exact match for the actual % and _ characters, use the ESCAPE
identifier. This option specifies what the escape character is. If you want to search for strings that contain SA_,
you can use the following SQL statement:
SELECT employee_id, last_name, job_id
FROM employees WHERE job_id LIKE ‘%SA\\_%’ ESCAPE ‘\\’;
> select * from spares
PART_CODE
———-
A%_WQ123
A%BWQ123
AB_WQ123
> select part_Code from spares where part_code like ‘%\%_WQ12%’ ESCAPE ‘\’
PART_CODE
———-
A%_WQ123
A%BWQ123
Correct is indeed D