Sunday, July 8, 2012

MySQL IsNullOrEmpty

MySQL does not have the IsNullOrEmpty function which checks if a particular field is null or empty. The only way to do it is by using the case statement. See below:


 SELECT CASE WHEN isnull(fieldname) or trim(fieldname) = '' THEN 0 ELSE 1 END FROM tablename;  

No comments:

Post a Comment