आप CASE
. का उपयोग कर सकते हैं :
select concat(first_name, " ", last_name) as CustomerName,
address,
case when address2 is null then 'None Provided' else address2 end as address2,
postal_code
from customer
inner join address
using (address_id);
या और भी बेहतर COALESCE
:
select concat(first_name, " ", last_name) as CustomerName,
address,
COALESCE(address2,'None Provided') as address2,
postal_code
from customer
inner join address
using (address_id);
यदि डेटा में एक खाली स्ट्रिंग या नल है, तो मैं इसका उपयोग करने पर विचार करूंगा:
select concat(first_name, " ", last_name) as CustomerName,
address,
case
when address2 is null or address2 = ''
then 'None Provided'
else address2 end as address2,
postal_code
from customer
inner join address
using (address_id);