Is there any difference between MySQL
IF (myText IS NOT NULL) THEN
and
IF (myText != '') THEN
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes there is a big difference between a
NULLvalue and a blank/empty value.Here’s one resource that describes the differences.
When
myText IS NULL:myText IS NOT NULLevaluates toFALSEmyText != ''evaluates toNULL(which essentially behaves the same asFALSEwould in this specific case you wrote)However, you should not get into the habit of treating them the same, since most of the time they will behave differently: For example:
Assume you have a table
tbl:Note: 1 contains a
NULLvalue, and 2 contains an empty string ('').If you run the following query:
… it will return record 3.
If you run the following query:
… it will return records 2 and 3.