ewom2468 ewom2468 - 1 year ago 113
SQL Question

Concat Values In MySQL Query(To Handle Null Values)

I am writing a PHP and MySQL application in which i have to concatenate multiple column values into one single column.I would have used the concat() function,but it does not handle null values,and the concat_ws(),which does not return the result in the output i want.
What i need can be achieved in the Oracle database like this:

Select 'The Surname Is'||last_name from employees;

My Issue is how can i achieve this same result with MySQL..without using the above named functions?

Answer Source


  CONCAT('The Surname Is ', IFNULL(last_name, 'sadly not available'))
FROM `employees`
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download