gammaman Posted April 21, 2008 Share Posted April 21, 2008 Can I test for NULL in a query, something like this, but this does not work. $result=mysql_query("select CourseID,StudentID, Grade FROM Rcourse WHERE CourseID ='$CourseID' AND StudentID = '{$_SESSION['student']['user']}' AND Grade = NULL"); Link to comment https://forums.phpfreaks.com/topic/102218-check-for-null-in-query/ Share on other sites More sharing options...
dptr1988 Posted April 21, 2008 Share Posted April 21, 2008 Use 'Grade IS NULL' rather then 'Grade = null' Link to comment https://forums.phpfreaks.com/topic/102218-check-for-null-in-query/#findComment-523270 Share on other sites More sharing options...
dptr1988 Posted April 21, 2008 Share Posted April 21, 2008 Some more info from the mysql manual: http://dev.mysql.com/doc/refman/5.0/en/working-with-null.html Link to comment https://forums.phpfreaks.com/topic/102218-check-for-null-in-query/#findComment-523271 Share on other sites More sharing options...
gammaman Posted April 21, 2008 Author Share Posted April 21, 2008 No, that did not work. Maybe I am not explaining myself correctly. I want the query to select the row where the Grade field has no value yet. Link to comment https://forums.phpfreaks.com/topic/102218-check-for-null-in-query/#findComment-523329 Share on other sites More sharing options...
dptr1988 Posted April 21, 2008 Share Posted April 21, 2008 What is the default value for the grade column? If the column definition contains a default value, then use that value. Link to comment https://forums.phpfreaks.com/topic/102218-check-for-null-in-query/#findComment-523335 Share on other sites More sharing options...
DarkWater Posted April 21, 2008 Share Posted April 21, 2008 $result=mysql_query("select CourseID,StudentID, Grade FROM Rcourse WHERE CourseID ='$CourseID' AND StudentID = '{$_SESSION['student']['user']}' AND Grade IS NULL"); That SHOULD work. O_O Works for me. Link to comment https://forums.phpfreaks.com/topic/102218-check-for-null-in-query/#findComment-523336 Share on other sites More sharing options...
gammaman Posted April 21, 2008 Author Share Posted April 21, 2008 The default value is NULL, meaning there is no defalut value. Still cannot get it working. Link to comment https://forums.phpfreaks.com/topic/102218-check-for-null-in-query/#findComment-523361 Share on other sites More sharing options...
DarkWater Posted April 21, 2008 Share Posted April 21, 2008 Do you get any mysql errors, or just no rows returned? Link to comment https://forums.phpfreaks.com/topic/102218-check-for-null-in-query/#findComment-523363 Share on other sites More sharing options...
gammaman Posted April 21, 2008 Author Share Posted April 21, 2008 Funny, but your code seems to be working now, I think I may have forgotten to reload the page after uploading the new version onto the server. I will let you know if I run into any more problems. P.S. : I don't have the code available right now but you were helping me with an insert query using $_SESSIONS early today and I still cannot get that working either. Thanks for all of your help. Link to comment https://forums.phpfreaks.com/topic/102218-check-for-null-in-query/#findComment-523372 Share on other sites More sharing options...
DarkWater Posted April 21, 2008 Share Posted April 21, 2008 If you want me to really look at the INSERT issue, censor out your database details and send me the connect, config, and insert scripts and I'll have a look. Put them all in a zip or tar file and put them on like, megaupload. Link to comment https://forums.phpfreaks.com/topic/102218-check-for-null-in-query/#findComment-523375 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.