OCP-1Z0-051 第59题 null值判断

一、原题
View the Exhibit and examine the data in the PRODUCTS table.
You need to display product names from the PRODUCTS table that belong to the 'Software/Other ' category with minimum prices as either $2000 or $4000 and no unit of measure.
You issue the following query:
SQL>SELECT prod_name, prod_category, prod_min_price
            FROM products
         WHERE prod_category LIKE '%Other%'
              AND (prod_min_price = 2000 OR prod_min_price = 4000) 
              AND prod_unit_of_measure <> '';
Which statement is true regarding the above query?
 
A. It executes successfully but returns no result.
B. It executes successfully and returns the required result.
C. It generates an error because the condition specified for PROD_UNIT_OF_MEASURE is not valid.
D. It generates an error because the condition specified for the PROD_CATEGORY column is not valid.

答案:A
二、题目翻译
下面是PRODUCTS表的数据:
现在要显示PRODUCTS表中产品种类为Software/Other,最低价格为$2000或$4000,并且没有度量单位的产品名称。
下面的查询语句哪句的正确的?
A 执行成功但不返回结果。
B 执行成功并返回所需结果。
C 报错因为PROD_UNIT_OF_MEASURE条件是无效的。
D 报错因为PROD_CATEGORY条件是无效的。
三、题目解析
因为prod_unit_of_measure <> ''该条件为假,’’和NULL类似,不能用<>这种方式来判断,而应该用is not null,所以会导致该WHERE子句里所有AND连接的值为假,虽然执行成功但不会返回结果,正确的条件应该是prod_unit_of_measure is not null。
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值