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

Asked

Viewed 54 times

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 it have a way of concatenating?

1 answer

4

To concatenate into the MySQL have to use the function CONCAT, 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 function CONCAT here.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.