Jonathan Green
Jonathan Green

Reputation: 57

How to build an an address label from multiple fields

I have some fields that form an address, which for the sake of argument has 5 address lines:

line1,
line2,
line3,
line4,
line5.

All of which are their own column in the table.

Is there a way within mysql to express this as one memo field as an address label? (with linebreaks)

Upvotes: 1

Views: 55

Answers (1)

user557846
user557846

Reputation:

how about:

concat_ws('<br>',
        IF(LENGTH(`address1`),`address1`,NULL),
        IF(LENGTH(`address2`),`address2`,NULL),
        IF(LENGTH(`address3`),`address3`,NULL)

)

Upvotes: 1

Related Questions