how do I pull the result of a column inside a string in mysql

0

example:

select 
    case
        when campo = 1 then 'existe o resultado='aqui eu colocaria o nome da coluna da tabela 'fim da string'
        else 0
    end 
from banco.tabela;

How would you do that have a way of concatenating?

    
asked by anonymous 11.04.2018 / 14:42

1 answer

4

To concatenate in MySQL you have to use the function CONCAT , it would look like this:

SELECT 
    CASE
        WHEN campo = 1 THEN CONCAT('existe o resultado=', banco.tabela.coluna, 'fim da string')
        ELSE 0
    END 
FROM banco.tabela;

See more about the CONCAT function here .     

11.04.2018 / 14:45