If you are going to get NULL values from database you can use IS NULL after WHERE condition.
Suppose you have a table named "products". There are three fields(id, pro_name, in_stock) in your table.
In your table (products):
- id — primary key, int type and auto_increment.
- pro_name — varchar type and default value is NULL.
- in_stock — varchar type and default value is NULL.
In the "pro_name" field, there are many product name and for each product name the "in_stock" field is only fill up by one (1) this mean product is available otherwise value is NULL. Now, if you want to fetch product name which value is NULL of is_stock field then you can use IS NULL. Using IS NULL you will get NULL values from database table.
In the following table i am going to show NULL values from MySQL Query.
Table Design: There is a Table named "products" with three(id, pro_name, in_stock) fields.QUERY EXAMPLE:
mysql_query("SELECT pro_name FROM products WHERE in_stock IS NULL");
RESULT:
You will get all product name which is_stock value is NULL.
EmoticonEmoticon