本文介绍了使用isnull和coalesce重写SQL查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
rewrite below incorrect statement in two ways using isnull and coalesce
select * from Test_Table where Test_ID=null
我尝试过:
What I have tried:
rewrite below incorrect statement in two ways using isnull and coalesce
select * from Test_Table where Test_ID=null
推荐答案
SELECT TOP 10 *
FROM Google
WHERE (NULL, Coalesce) IN SearchTerms
--if first column/Test_ID is null, use value from second column which is ''
SELECT *
FROM Test_Table
WHERE COALESCE(Test_ID, '') = ''
--if Test_ID is null, return ''
SELECT *
FROM Test_Table
WHERE ISNULL(Test_ID,'') = ''
在这里你可以找到更多关于上述功能的信息。
[]
[]
这篇关于使用isnull和coalesce重写SQL查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!