Jump to content

[SOLVED] Query looking for Null field


ballouta

Recommended Posts

Hi

 

i have the table 'upload' where the following rows:

 

ID  user      file        sentdate          receiveddate

5    Malek    12.ask    2008-07-22      NULL

9    Malek    12.ask    2008-07-22      2008-07-22

 

receiveddate field is of type date, and it may be NULL.

 

i want to fix this query to get the row of ID = 5

 

<?php
$query = "SELECT * FROM `upload` WHERE `user` = 'Malek' AND `file` = '12.ask' AND `receiveddate` = NULL ";
?>

 

it is Not working

please help

Link to comment
https://forums.phpfreaks.com/topic/116002-solved-query-looking-for-null-field/
Share on other sites

When you inserted record 5 did you do:

INSERT INTO upload VALUES(''. 'Malek', '12.ask', '2008-07-22', 'NULL')

or

INSERT INTO upload VALUES(''. 'Malek', '12.ask', '2008-07-22', '')

 

If you did the first try this

<?php
$query = "SELECT * FROM `upload` WHERE `user` = 'Malek' AND `file` = '12.ask' AND `receiveddate` = 'NULL' ";
?>

I changed the insertion code, it is now:

 

INSERT INTO upload VALUES(''. 'Malek', '12.ask', '2008-07-22', 'NULL')

 

the MySQl table shows that the receiveddate field is now by defualt 000-00-00

 

now i am able to look for the row that has empty (0000-00-00) field

 

thank you

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.