Isnull和''在sql查询中的混淆

编程入门 行业动态 更新时间:2024-10-27 10:30:00
本文介绍了Isnull和''在sql查询中的混淆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

heyy .. 我对Isnull查询感到困惑... 在我的桌子上我有一个空白值的字段(客户名称).........当我写这样的查询时..

heyy.. I am confused with Isnull query ... IN my table I have a field(customer Name) with a blank value......... when i write query like this..

select * from dbo.M_CustomerMasterDetails where CustomerMasterId=281 and ( CustomerName = is null; PartyCode =is null)

我没有得到结果.... 但是当我写查询链接时这个..

I don't get the result .... But when I write query link this..

select * from dbo.M_CustomerMasterDetails where CustomerMasterId=281 and ( CustomerName = '' PartyCode ='')

我得到了结果... 什么是差异b / w为空和''在sql中。 .....

I got result... what is the diffrence b/w is null and ' ' in sql......

推荐答案

Null表示该值未知。 ''表示有一个值,并且它是一个空字符串。 如果你的数据库允许CustomerName和PartyCode字段的空值,您需要在查询中检查它们。一种选择是: Null means the value is unknown. '' means that there is a value, and that it's an empty string. If your database allows nulls for the CustomerName and PartyCode fields, you would need to check for them in your query. One option would be this: select * from dbo.M_CustomerMasterDetails where CustomerMasterId= 281 and ( isnull(CustomerName, '') = '' or isnull(PartyCode, '') = '')

As除此之外,您的查询中存在语法错误。这可能会解决您的一些问题。

As an aside, there are syntax errors in your queries above. That might account for some of your issues.

更多推荐

Isnull和''在sql查询中的混淆

本文发布于:2023-11-09 05:17:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1571482.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Isnull   sql

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!