affc Posted April 5, 2009 Share Posted April 5, 2009 This code wont work for some reason, it wont update all the field with NULL <? $var = NULL; $sql5="UPDATE Details SET datapoint='4' WHERE set='$var'"; $result5=mysql_query($sql5) or die ("SQL Error: $sql5<br>" . mysql_error()); ?> Link to comment https://forums.phpfreaks.com/topic/152633-solved-cannot-restrict-and-find-only-the-null-fields-in-a-database/ Share on other sites More sharing options...
MasterACE14 Posted April 5, 2009 Share Posted April 5, 2009 try... $sql5="UPDATE Details SET datapoint='4' WHERE set='NULL'"; if you want it input as a string or... $sql5="UPDATE Details SET datapoint='4' WHERE set=''"; if you want the value to be nothing(I think) Regards, ACE EDIT: actually on second thought that doesn't make sense. Link to comment https://forums.phpfreaks.com/topic/152633-solved-cannot-restrict-and-find-only-the-null-fields-in-a-database/#findComment-801576 Share on other sites More sharing options...
Yesideez Posted April 5, 2009 Share Posted April 5, 2009 $sql5="UPDATE `Details` SET `datapoint`='4' WHERE `set`=NULL"; Link to comment https://forums.phpfreaks.com/topic/152633-solved-cannot-restrict-and-find-only-the-null-fields-in-a-database/#findComment-801577 Share on other sites More sharing options...
Yesideez Posted April 5, 2009 Share Posted April 5, 2009 If you enclose the word NULL in single quotes MySQL will treat it as a string (string of "NULL") and not a value. Link to comment https://forums.phpfreaks.com/topic/152633-solved-cannot-restrict-and-find-only-the-null-fields-in-a-database/#findComment-801579 Share on other sites More sharing options...
affc Posted April 5, 2009 Author Share Posted April 5, 2009 Yeah i tried putting it as just "NULL" will try "=NULL" Thank you so much Link to comment https://forums.phpfreaks.com/topic/152633-solved-cannot-restrict-and-find-only-the-null-fields-in-a-database/#findComment-801581 Share on other sites More sharing options...
affc Posted April 5, 2009 Author Share Posted April 5, 2009 Nope, "=NULL" doesn't worth either i have tried a few different ways but nothing working so far Link to comment https://forums.phpfreaks.com/topic/152633-solved-cannot-restrict-and-find-only-the-null-fields-in-a-database/#findComment-801582 Share on other sites More sharing options...
Yesideez Posted April 5, 2009 Share Posted April 5, 2009 Well, that's the correct way to do it. I'd check the rest of the table and make sure `set` can actually be NULL and if `datapoint` can be set to 4 because something is failing somewhere. Link to comment https://forums.phpfreaks.com/topic/152633-solved-cannot-restrict-and-find-only-the-null-fields-in-a-database/#findComment-801584 Share on other sites More sharing options...
affc Posted April 5, 2009 Author Share Posted April 5, 2009 Yeah I have the field set to Int(5) and default is NULL, just want to be able to access only the NULL fields in the table but not workin Link to comment https://forums.phpfreaks.com/topic/152633-solved-cannot-restrict-and-find-only-the-null-fields-in-a-database/#findComment-801588 Share on other sites More sharing options...
Yesideez Posted April 5, 2009 Share Posted April 5, 2009 $sql5="UPDATE `Details` SET `datapoint`='4' WHERE `set` IS NULL"; Link to comment https://forums.phpfreaks.com/topic/152633-solved-cannot-restrict-and-find-only-the-null-fields-in-a-database/#findComment-801590 Share on other sites More sharing options...
affc Posted April 5, 2009 Author Share Posted April 5, 2009 Works perfectly, thank you how do I change this to Solved? $sql5="UPDATE `Details` SET `datapoint`='4' WHERE `set` IS NULL"; Link to comment https://forums.phpfreaks.com/topic/152633-solved-cannot-restrict-and-find-only-the-null-fields-in-a-database/#findComment-801591 Share on other sites More sharing options...
Yesideez Posted April 5, 2009 Share Posted April 5, 2009 Should be a "Solved" button in the bottom left of the post list. Just CTRL-F and type "solved" and the browser should tell you. Glad it worked btw, to check for the opposite use IS NOT NULL EDIT: Got my left and right muddled up :/ Link to comment https://forums.phpfreaks.com/topic/152633-solved-cannot-restrict-and-find-only-the-null-fields-in-a-database/#findComment-801592 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.