MySQL Replace Null with an Empty String

Viewed 204

I have this table

user_id title
1 ABCD
1 null
2 EFGH

I'am trying to get all the titles of every user id and convert null to an empty string.

I tried using this

SELECT IFNULL(title, '') FROM table WHERE user_id = 1

But it says that multiple rows returned, when I try 2 it returns a result.

Is there a way to convert all null relut to empty string if ther more than 1 result? Thanks.

2 Answers

You can use COALESCE() to replace NULL with an empty string.

You can find a detailed answer on the following link.

Hope it resolves your issue.

Thanks

Related