One last try on evaluating nulls.
Posted: Wed Mar 23, 2005 7:01 am
Sorry to repeat myself, but as this week is the first time I've even looked at MySql ( I'm a dba ) I have a major problem comparing null values. The following is a defined statement to be called when comparing input on a form to that in the underlying table to achieve a match:-
These 2 lines:-
all_modules.Prereq_for = \'' .$_POST["pre-requisite$i"] . '\' and all_modules.Coreq_for = \'' .$_POST["co-requisite$i"] . '\' and
compare values which can be null, and default to null. There must be a match between them. However I know that you can't use '=' with nulls and should check them using is null/is not null. Would you have to do the comparison using a nested sub-query, and if so what would the format be ? It seems a little clumsy to do the evaluation in such a query for each item, set a flag for them and compare, but even if this was the way to do it, I don't know how to code it. Any help would be greatly appreciated !
feyd | Please review how to post code using
Code: Select all
// Create the sql query
$consistency = ('SELECT all_modules.Module_code, all_modules.Module_title, all_modules.Module_credits, all_modules.New_module, all_modules.Prereq_for, all_modules.Coreq_for, is_specific.Pass_required FROM all_modules INNER JOIN is_specific ON all_modules.Module_code = is_specific.Module_code WHERE all_modules.Module_code = \'' . $_POST["code$i"] . '\' and all_modules.Module_title = \'' . $_POST["title$i"] . '\' and all_modules.Module_credits = \'' . $_POST["credits$i"] . '\' and all_modules.New_module = \'' . $_POST["new$i"] . '\' and all_modules.Prereq_for = \'' . $_POST["pre-requisite$i"] . '\' and all_modules.Coreq_for = \'' . $_POST["co-requisite$i"] . '\' and is_specific.Pass_required = \'' . $_POST["pass$i"] . '\' ');all_modules.Prereq_for = \'' .$_POST["pre-requisite$i"] . '\' and all_modules.Coreq_for = \'' .$_POST["co-requisite$i"] . '\' and
compare values which can be null, and default to null. There must be a match between them. However I know that you can't use '=' with nulls and should check them using is null/is not null. Would you have to do the comparison using a nested sub-query, and if so what would the format be ? It seems a little clumsy to do the evaluation in such a query for each item, set a flag for them and compare, but even if this was the way to do it, I don't know how to code it. Any help would be greatly appreciated !
feyd | Please review how to post code using
Code: Select all
andCode: Select all
tags. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]