Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I've one SQL table with different fields. Now i want to check all the values whether it's null or not and select only those values which are not null. How can i do that? Some one please help me.

Thanks in advance,
Ajay
Posted
Comments
Adarsh chauhan 5-Jul-13 7:58am    
what do you mean by " i want to check all the values whether it's null or not and select only those values which are not null"
both cases are different. please clarify what you want to achieve and if possible provide your table and sample data
ajaykalarickal 5-Jul-13 9:10am    
like this,

id name age
1 null null

null null 8

null sony null

the output should be like this-

1
8
sony

I hope it's more clear now.

Both are different cases.

If you want to check all the values whether it's null or not

use

SQL
select * from TableName 


and if you want to check all the values which are not null.

use

select * from TableName where ColumnName is not null


But i don't think that you want to ask this, as even a beginner in sql knows the how to use is null and is not null in where clause.

so please clarify what you want to achieve and provide sample table, data and your goal.
 
Share this answer
 
v2
like this,

id name age
1 null null

null null 8

null sony null

the output should be like this-

1
8
sony

I hope it's more clear now.
 
Share this answer
 
try this...:)


SQL
SELECT columnName FROM TableName WHERE columnName IS NOT NULL
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900