Page 1 of 1

how to check a column without data?

Posted: Wed Jan 10, 2007 2:08 pm
by saumya
hi guys,
can anybody tell me how to check a column in a table for not having any data. Rightnow I am using below code without any success

Code: Select all

$query = "SELECT * FROM `nt_students` WHERE `wo`='$WorkOrderNumber' AND `sub_group`='';";
thanks

Posted: Wed Jan 10, 2007 2:11 pm
by TheMoose

Code: Select all

SELECT * FROM nt_students WHERE wo='$WorkOrderNumber' AND sub_group IS NULL;
That's solely dependent on whether the column allows null values or not.

Posted: Wed Jan 10, 2007 2:18 pm
by saumya
Thank you so much.That worked.
But what if the column is set not to accept NULL values.How can I check then?

Posted: Thu Jan 11, 2007 7:50 pm
by califdon
saumya wrote:Thank you so much.That worked.
But what if the column is set not to accept NULL values.How can I check then?
If the column doesn't accept NULL values, there won't BE any NULL values to check for...

Posted: Thu Jan 11, 2007 10:29 pm
by saumya
yes, exactly. Then how can i check those columns?

Posted: Thu Jan 11, 2007 10:44 pm
by feyd
What have you tried to figure out the answer?

Posted: Fri Jan 12, 2007 6:25 am
by saumya
hi,
I have made the value of the column to accept "NULL"

Preveously I was checking with blank string "" but without any success.