这两个查询之间的区别? [英] difference between these two queries?
本文介绍了这两个查询之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
SELECT DBName,ConnString + ' #VIJAY#' + FinanceConnString + ' #VIJAY#' +
RptDBConnString AS ConStr FROM [ DataBase ] WHERE Active = 1
从[database]中选择dbname,connstring作为ConStr,其中active = 1
给出相同的结果,那么上面两个查询之间的区别是什么?plz解释...
在第一个查询中为什么我们r使用+''#VIJAY#''+ FinanceConnString +''#VIJAY#''+
RptDBConnString
解决方案
2个查询将给出如果ConnString列为NULL,则结果相同,因为
NULL +任何事都是NULL。
要查看2个查询之间的区别,请使用 ISNULL [ ^ ]
尝试
SELECT DBName ,ISNULL(ConnString,' ')+ ' #VIJAY#' + ISNULL(FinanceConnString,' ')+ ' #VIJAY#' +
ISNULL(RptDBConnString,< span class =code-string>' ') AS ConStr FROM [ DataBase ] WHERE Active = 1 跨度>
SELECT DBName, ConnString + '#VIJAY#' + FinanceConnString + '#VIJAY#' +
RptDBConnString AS ConStr FROM [DataBase] WHERE Active = 1
select dbname, connstring as ConStr from [database] where active=1
giving same result,so what is the diff between above two queries?Plz explain...
in 1st query why we r using+ ''#VIJAY#'' + FinanceConnString + ''#VIJAY#'' +
RptDBConnString
解决方案
The 2 queries will give same result if ConnString column is NULL because
NULL + Anything is NULL.
To see the difference between 2 queries use ISNULL[^]
Try
SELECT DBName, ISNULL(ConnString,'') + '#VIJAY#' + ISNULL(FinanceConnString,'') + '#VIJAY#' + ISNULL(RptDBConnString,'') AS ConStr FROM [DataBase] WHERE Active = 1
这篇关于这两个查询之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文