本文介绍了如何在查询中使用Isnull函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 HEllo团队, 我有以下查询。 选择 ID,CUSTOMERLOANOCRID,FILELOGID,[FILENAME],BATCHID,RECORDNO,FIRSTNAME, MIDDLENAME,LASTNAME,GENDER,FULLADDRESS,CUSTOMERADDR1,CUSTOMERADDR2,LANDMARK ,CITY,STATE, PINCODE,LANDLINENO,MOBILENO1,MOBILENO2,EMAILID,DOB,ADDRVERIFY, PHOTOVERIFY,LOAN1AMT,LOAN1INTRRATE,LOAN2AMT,LOAN2INTRRATE,DATEOFEMI,RELEASEDATE, MOTHERNAME,HOUSETYPE,COMPANYNAME ,SALARY,IMAGENAME,IMAGERECORDNO,QCTOVERIFY, QCUSERID,CREATEDBY,CREATEDON,UPDATEDBY,UPDATEDON,DELETED,QCUSERID,QCTOVERIFY, QCTOVERIFYREMARKS 来自 CUSTOMERLOANDATA with ( nolock ) 其中 FILELOGID =(选择 top ( 1 )filelogid 来自 CUSTOMERLOANDATA with ( nolock ) 其中 isnull(QCTOVERIFY, 0 )和 QCUSERID = 13 订单 by id asc )和 isnull(QCTOVERIFY, 0 ) 我收到错误 消息 4145 ,等级 15 ,状态 1 ,行 9 表达式 非boolean 类型指定 上下文 where 条件 预期,接近' 和' 请告诉我我在哪里犯了错误。 谢谢 Harshal Raut 解决方案 您在ISNULL部分没有任何条件。 ISNULL不返回传递给它的列的true或false id为null,而是第二个参数。 在你的情况下 ISNULL (QCTOVERIFY, 0 ) 将返回 QCTOVERIFY 如果它不是null并且 0 它就是null。 所以你必须改变你的ISNULL问题: ISNULL(QCTOVERIFY, 0 )= 0 如果你检查null ISNULL(QCTOVERIFY, 0 )<> 0 如果检查非空 从 表 -keyword> where QCTOVERIFY null HEllo Team,I have the following Query.select ID,CUSTOMERLOANOCRID,FILELOGID,[FILENAME],BATCHID,RECORDNO,FIRSTNAME,MIDDLENAME,LASTNAME,GENDER,FULLADDRESS,CUSTOMERADDR1,CUSTOMERADDR2,LANDMARK,CITY,STATE, PINCODE , LANDLINENO, MOBILENO1 , MOBILENO2 , EMAILID , DOB , ADDRVERIFY , PHOTOVERIFY , LOAN1AMT , LOAN1INTRRATE, LOAN2AMT,LOAN2INTRRATE,DATEOFEMI,RELEASEDATE, MOTHERNAME , HOUSETYPE ,COMPANYNAME,SALARY,IMAGENAME , IMAGERECORDNO, QCTOVERIFY , QCUSERID , CREATEDBY , CREATEDON , UPDATEDBY , UPDATEDON , DELETED ,QCUSERID ,QCTOVERIFY,QCTOVERIFYREMARKS from CUSTOMERLOANDATA with(nolock)where FILELOGID=(select top(1) filelogid from CUSTOMERLOANDATA with(nolock) where isnull (QCTOVERIFY , 0) and QCUSERID = 13 order by id asc) and isnull (QCTOVERIFY, 0)I am getting the errorMsg 4145, Level 15, State 1, Line 9An expression of non-boolean type specified in a context where a condition is expected, near 'and'Kindly tell me where i am making the mistake.ThanksHarshal Raut 解决方案 You have no condition in the ISNULL part. ISNULL does not returns a true or false id the column passed to it is null, rather the second parameter.In your caseISNULL(QCTOVERIFY, 0)Will return the value of QCTOVERIFY if it's not null and 0 it it is null.So you have to change your ISNULL question like this:ISNULL(QCTOVERIFY, 0) = 0 if you check for nullISNULL(QCTOVERIFY, 0) <> 0 if you check for non-nullselect * from table where QCTOVERIFY is null 这篇关于如何在查询中使用Isnull函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-17 22:36