Re: In Stored Procedure, how to check if variable is NULL?
BTW, what is
UserID <> NULL
supposed to do anyway? As far as i can see, this *never* evaluates to TRUE, even if UserID would be NULL. In fact, anything compared to NULL using a relational operator always evaluates to UNKNOWN. Now, UNKNOWN is not exactly FALSE, but is definitely is not TRUE, so, the IF branch never executes.
This behaviour has nothing to do with the platform, NULLs behave similar in MSSQL and MySQL in this respect.
...
There's something else: IF statements in MySQL are blocks. You should end an IF using an END IF:
IF l_UserID IS NULL
SELECT FirstName, LastName, EMail FROM Users WHERE UserID = l_UserID;
END IF;
This is just illustration, for a solutions, stick to what I posted earlier.