一、原題
You need to extract details of those products in the SALES table where the PROD_ID column contains the string '_D123'.
Which WHERE clause could be used in the SELECT statement to get the required output?
A. WHERE prod_id LIKE '%_D123%' ESCAPE '_'
B. WHERE prod_id LIKE '%\_D123%' ESCAPE '\'
C. WHERE prod_id LIKE '%_D123%' ESCAPE '%_'
D. WHERE prod_id LIKE '%\_D123%' ESCAPE '\_'
答案 B
二、題目翻譯
要從SALES表中提取出PROD_ID列包含'_D123'字元串的産品明細。
下面哪一個WHERE條件子句可以獲得所需的輸出結果?
三、題目解析
ESCAPE子句為指定轉譯字元,因為'_'下畫線在LIKE子句中指的是任意一個字元,是以需要把'_'下畫線進行轉義,轉義字元設定為'\'。