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.

I have tried doing WHERE clause

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

It didnot work.

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

Also check if the column contains any white spaces.

Is there other option to do it?

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)

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?

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

can u post some sample data here.

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'

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

delete * from table1 where grade is null

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.