ballouta Posted July 22, 2008 Share Posted July 22, 2008 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 More sharing options...
unkwntech Posted July 22, 2008 Share Posted July 22, 2008 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' "; ?> Link to comment https://forums.phpfreaks.com/topic/116002-solved-query-looking-for-null-field/#findComment-596415 Share on other sites More sharing options...
ballouta Posted July 22, 2008 Author Share Posted July 22, 2008 No i am using the second one i can see in phpmyadmin page in the table the NULL word but the query u write is not working Link to comment https://forums.phpfreaks.com/topic/116002-solved-query-looking-for-null-field/#findComment-596421 Share on other sites More sharing options...
unkwntech Posted July 22, 2008 Share Posted July 22, 2008 Have you tried: <?php $query = "SELECT * FROM `upload` WHERE `user` = 'Malek' AND `file` = '12.ask' AND `receiveddate` = '' "; ?> Link to comment https://forums.phpfreaks.com/topic/116002-solved-query-looking-for-null-field/#findComment-596424 Share on other sites More sharing options...
ballouta Posted July 22, 2008 Author Share Posted July 22, 2008 yes actually i did I tried both = '' and ' ' i thought maybe there's difference but 0 results Link to comment https://forums.phpfreaks.com/topic/116002-solved-query-looking-for-null-field/#findComment-596427 Share on other sites More sharing options...
unkwntech Posted July 22, 2008 Share Posted July 22, 2008 I'm not sure on this one sorry. ??? Link to comment https://forums.phpfreaks.com/topic/116002-solved-query-looking-for-null-field/#findComment-596431 Share on other sites More sharing options...
ballouta Posted July 22, 2008 Author Share Posted July 22, 2008 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 Link to comment https://forums.phpfreaks.com/topic/116002-solved-query-looking-for-null-field/#findComment-596433 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.