Tony Stark
Tony Stark

Reputation: 302

MySQL Replace Null with an Empty String

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.

Upvotes: 3

Views: 1538

Answers (2)

digitalbarista
digitalbarista

Reputation: 1

You can find a detailed answer on the following link.

Hope it resolves your issue.

Thanks

Upvotes: 0

Sneha Ashtekar
Sneha Ashtekar

Reputation: 134

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

Upvotes: 1

Related Questions