3. 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 '\_'
Answer: B
题目解析:
题意是:要在Sales表中查询 PROD_ID字段中含有字符串'_D123'的行
_下划线在like字句中是代表任意一个字符,现在要匹配'_D123'就需要对_下划线进行转义,所以正确的答案是B,转义字符是'\'
转载于:https://www.cnblogs.com/wjx515/p/3808591.html
本文介绍在SQL查询中如何正确使用LIKE子句及转义字符来匹配包含特殊字符的字符串,具体示例为查询含有'_D123'的产品ID。
9735

被折叠的 条评论
为什么被折叠?



