How to replace NULL value of specific column with other column value. For example: If second name of customer is not given then add father name in second name column.
5 Answers
Try with case statement as below-
SELECT
CASE
WHEN second_name IS NULL OR second_name = '' THEN father_name
ELSE second_name
END AS second_name
FROM your_table
You can use COALESE
SELECT COALESE(second_name, first_name) from mytable;
AFAIK, it is supported on Oracle, MS SQL Server, MySQL and Postgres.