970_90

Tuesday, 1 September 2015

MySql replace NULL values with empty string without effecting Rowset

MySql replace NULL values with empty string without effecting Rowset

Question: What is NULL Value in MySQL?
NULL values means don't have any value. It is neither empty NOR it have any value.


Question: Give an Example which is give NULL Values in Query?
NULL values means don't have any value. It is neither empty NOR it have any values.
SELECT u.id, u.first_name,u.last_name,b.address1 FROM `users` as u LEFT JOIN billings as b on b.user_id=u.id order by u.id desc limit 5;
See Screenshot below:
Give an Example which is give NULL Values in Query



Question: How we can replace the null value with empty string?
We can use mysql IFNULL function to replace the null values with empty string. See Example:
SELECT IFNULL(null,"") as value 



Question: Give an Example to replace the NULL with empty string in mysql query?
We can use mysql IFNULL function to replace the null values with empty string. See Example:
SELECT u.id, u.first_name,u.last_name,IFNULL(b.address1,"") AS address1 FROM `users` as u LEFT JOIN billings as b on b.user_id=u.id  order by u.id desc limit 5; 

See Screenhot below:
Give an Example to replace the NULL with empty string in mysql query





No comments:

Post a Comment