Reputation: 6365
Why is my entire string blank when I output data using php doing:
select concat(name, desc) as output from reports where type=2
And the data in the table is:
Name Desc
a desc a
b null
c null
Output using php:
a desc a
blank space
blank space
If I didn't use concat
, the output is as usual. I'm using concat
so I can output everything in one variable when using php.
Upvotes: 1
Views: 60
Reputation: 263713
you can use CONCAT_WS()
concat_ws('', name, `desc`)
or with COALESCE()
concat(name, COALESCE(`desc`,''))
Upvotes: 1