Include null values in querry
Posted: Fri Dec 15, 2006 8:18 am
Hi there,
Is there any way to include the null values in a querry?
What i am doing exactly is that i have a form from where i give some minimum and maximum values for some fields and pass it to a PHP script to execute a querry. In the querry i use the
where field1 between field1_min and field2_min and all is allright.
What i want to do though, is to be able to give ALL the results, including the records with null value in that field, when the user selects as minimum and as maximum "Any". I want to do without making the code full of IF's and many different cases.
My code looks smth like that
WHERE price between $pricemin and $pricemax AND
size between $sizemin and $sizemax OR AND
extras_num between $extrassmin and $extrassmax
Any ideas?
Is there any way to include the null values in a querry?
What i am doing exactly is that i have a form from where i give some minimum and maximum values for some fields and pass it to a PHP script to execute a querry. In the querry i use the
where field1 between field1_min and field2_min and all is allright.
What i want to do though, is to be able to give ALL the results, including the records with null value in that field, when the user selects as minimum and as maximum "Any". I want to do without making the code full of IF's and many different cases.
My code looks smth like that
WHERE price between $pricemin and $pricemax AND
size between $sizemin and $sizemax OR AND
extras_num between $extrassmin and $extrassmax
Any ideas?