954,560 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

NULL Values

Hi everyone,
Thanks for viewing this post.

I have a question about SQL. May i know how to remove rows that have NULL value in one of the colums.

SELECT name, grade, age FROM education

If let say grade 1 of the rows is NULL, how do i remove that particular rows?
Please guide me thanks.

strRusty_gal
Light Poster
35 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

I have tried doing WHERE clause

SELECT name, grade, age FROM education
WHERE grade IS NOT NULL

It didnot work.

strRusty_gal
Light Poster
35 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

That should work, ensure that you are using where clause on the proper column.

Also check if the column contains any white spaces.

debasisdas
Posting Genius
6,872 posts since Feb 2007
Reputation Points: 666
Solved Threads: 434
 

Is there other option to do it?

strRusty_gal
Light Poster
35 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

first select whether your table has null rows or not.
run following queries one by one.

SELECT name, grade, age FROM education 
WHERE (grade IS  NULL )

SELECT name, grade, age FROM education 
WHERE ( name is null )

SELECT name, grade, age FROM education 
WHERE (age is null)


see whether you get any row(s) (having null value)

urtrivedi
Nearly a Posting Virtuoso
1,306 posts since Dec 2008
Reputation Points: 257
Solved Threads: 270
 

I did what you say. and run the query. the result is NONE.

so do you mean that i don't have any NULL value at all?

the result out before it was, there are cells that indicate NULL. how do i actually remove that particular rows?

strRusty_gal
Light Poster
35 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

if it is a word "NULL", how do i remove those rows? anyone got any idea?

strRusty_gal
Light Poster
35 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

can u post some sample data here.

debasisdas
Posting Genius
6,872 posts since Feb 2007
Reputation Points: 666
Solved Threads: 434
 

i think you do not have null vales in your database. What you have is 'NULL' word in columns, thats why my query did not show any result.

So now you can remove such rows by following query

delete from tablename where TRIM(grade)='NULL'
urtrivedi
Nearly a Posting Virtuoso
1,306 posts since Dec 2008
Reputation Points: 257
Solved Threads: 270
 

Hi,
Thanks for everyone help. I have solved the matter by placing another table. Thanks

strRusty_gal
Light Poster
35 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

delete * from table1 where grade is null

crishlay
Junior Poster
132 posts since May 2010
Reputation Points: 10
Solved Threads: 16
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You