想忽略SQL查询中的空值 [英] want to ignore the null values in sql query

查看:876
本文介绍了想忽略SQL查询中的空值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实际上我正在使用c#和sql2005
在查询中,我得到了很多空值.表示每行中都有一些包含空值的列.
我只想忽略该列.表示我要显示所有包含值的列.

请指教
在此先感谢

actually I am working in c# and sql2005
in query,am getting lot of null values. means there are some columns containing null values in each row.
i just want to ignore that column. means i want to show all columns containing values.

please advice
Thanks in Advance

推荐答案

SELECT Col1, Col2, Col3 
FROM Table1
WHERE (Col1 IS NOT NULL)
AND (Col2 IS NOT NULL)
AND (Col3 IS NOT NULL)


您可以尝试以下LINQ查询:

you can try following LINQ query:

var a = from p in obj.tableName where p.Col1 != null && p.Col2 != null select p;



如果仅通过SQL查询,则可以使用uper解决方案.

-Sagar Solanki



If you are going through SQL query only then uper sollution is fine.

-Sagar Solanki


选择*
从表1
Col1不为空的地方
SELECT *
FROM Table1
WHERE Col1 IS NOT NULL


这篇关于想忽略SQL查询中的空值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆