MySQL / Stored Procs / IFs / Variable Test for Null

ok, i’ve got a simple stored procedure that adds up values in a “Basket” 's items and sticks the total in the parent record.

But since i’ve added the “EMPTY BASKET” option, it’s falls over because the sum of the items is NULL.

Can you please tell me if this is correct (BELOW), if not, how cna i fix it:

SET varItemCount = (SELECT sum(Quantity) FROM tblbasketitem WHERE tblbasketitem.BasketID = varBasketID);
set varItemCount = NULL;
if varItemCount = null then
set varItemCount = 5;
set varItemCount = 9;
end if;

At the moment, it IS null, but it’s not recognising it as null…
I’ve inserted “set varItemCount = NULL;” to force it to NULL and it still comes up with ‘9’

please tell me what i’m doing wrong…

if varItemCount = null is the problem

try if varItemCount is null