【发布时间】:2022-01-28 00:27:17
【问题描述】:
| product_id | product_name | product_description |
|---|---|---|
| 1 | Fans | Panasonic fans |
| 2 | Refrigerator | Toshiba refrigerator |
| 3 | Light | Edison bulb |
| 4 | Laptop | NULL |
产品表如上图。
select *
from product
where isnull(product_description, null) = product_description
SQL 脚本是我要运行的。
我可以知道如何阅读或它对条件的实际含义吗?为什么没有选择第 4 行?感觉和查询一样
select *
from product
where product_description is not null
我对查询中的条件有点困惑。
【问题讨论】:
-
ISNULL(product_description, NULL) = product_description没有意义,如果 product_description 是NULL它会毫无意义地用NULL替换它,然后它会执行=条件,对于not nullproduct_description 只会是true.因此,正如您所怀疑的那样,这只是编写where product_description is not null的一种不必要的混淆方式 -
根据问题指南,请不要发布代码、数据、错误消息等的图像 - 将文本复制或输入到问题中。请保留将图像用于图表或演示渲染错误,无法通过文本准确描述的事情。
-
在尝试理解 T-SQL 函数时,阅读docs 应该始终是您的第一站。
标签: sql sql-server tsql