how to check a column without data?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
saumya
Forum Contributor
Posts: 193
Joined: Sun Jan 30, 2005 10:21 pm

how to check a column without data?

Post 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
User avatar
TheMoose
Forum Contributor
Posts: 351
Joined: Tue May 23, 2006 10:42 am

Post 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.
saumya
Forum Contributor
Posts: 193
Joined: Sun Jan 30, 2005 10:21 pm

Post 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?
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Post 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...
saumya
Forum Contributor
Posts: 193
Joined: Sun Jan 30, 2005 10:21 pm

Post by saumya »

yes, exactly. Then how can i check those columns?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

What have you tried to figure out the answer?
saumya
Forum Contributor
Posts: 193
Joined: Sun Jan 30, 2005 10:21 pm

Post 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.
Post Reply