How to return multiple fields as a single array or string?

-1

I have a table in the database with several phones, the name of the fields is numbered as follows: telefone1, telefone2, telefone3 your return is like this:

Array
(
    [telefone1] => 190
    [telefone2] => 197
    [telefone3] => 140
)

What I would like to do is to select, instead of returning multiple phones, return an array with all, something like this:

Array
(
    [telefone] => Array
        (
            [0] => 190
            [1] => 197
            [2] => 140
        )

)

Or merge the fields with some character, for example, comma:

190,197,140
    
asked by anonymous 30.06.2018 / 02:51

1 answer

2

You can use the command concat_ws , in the specification, it says uni string according to a tab, better explanation in link Your select would look like SELECT CONCAT_WS(" , ", telefone1, telefone2, telefone3) AS telefones , remembering that this works if the phones are strings.

    
30.06.2018 / 15:33