使用isnull和coalesce重写SQL查询

编程入门 行业动态 更新时间:2024-10-27 14:19:16
本文介绍了使用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

不清楚你的内容问题是。但这里有一个关于如何使用COALESCE和ISNULL函数的例子。 Not clear what your question is. But here an example on how to use COALESCE and ISNULL function. --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,'') = ''

在这里你可以找到更多关于上述功能的信息。 COALESCE(Transact-SQL)| Microsoft Docs [ ^ ] 在SQL Server中的COALESCE和ISNULL之间进行决策 [ ^ ]

更多推荐

使用isnull和coalesce重写SQL查询

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

发布评论

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

>www.elefans.com

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