How to check empty or null in Mysql Query?

How to check empty or null in Mysql Query?

In this post we will give you information about How to check empty or null in Mysql Query?. Hear we will give you detail about How to check empty or null in Mysql Query?And how to use it also give you demo for it if it is necessary.

If you want to check empty or null value with conditional statement like case when and if in table row with Mysql database. you like to check empty or null value form table then you have multiple way check that. first we check empty value with case when statement then following example.

Empty Check:

SELECT

(CASE WHEN COALESCE(email,'')!='' THEN email ELSE 'example@gmail.com' END) as test

FROM 'customers'

---------------------OR----------------------

SELECT

(CASE COALESCE(email,'') WHEN '' THEN 'example@gmail.com' ELSE email END) as test

FROM 'customers'

---------------------OR----------------------

SELECT

(IF(COALESCE(email,'')!='',email,'example@gmail.com')) as exp

FROM 'customers'

Null Check:

SELECT

(CASE WHEN email IS NULL THEN 'example@gmail.com' ELSE email END) as test

FROM 'customers'

---------------------OR----------------------

SELECT

(IF(email IS NULL,'example@gmail.com',email)) as exp

FROM 'customers'

Hope this code and post will helped you for implement How to check empty or null in Mysql Query?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

78  +    =  87

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US