1
I have this hypothetical function:
BEGIN
DECLARE dado VARCHAR(150);
SET dado = 'teste';
END;
How do I concatenate the variable dado
, as an example:
SET dado += ' teste2';
I tried this but it doesn’t work in Mysql.
1
I have this hypothetical function:
BEGIN
DECLARE dado VARCHAR(150);
SET dado = 'teste';
END;
How do I concatenate the variable dado
, as an example:
SET dado += ' teste2';
I tried this but it doesn’t work in Mysql.
5
2
concat(dado,'teste')
that would be it?
1
You can use the Concat both in a SELECT and within a FUNCTION.
Using in the SELECT:
SELECT CONCAT(coluna_1, " STRING ", coluna_2) AS STRING_CONCATENADA FROM SUA_TABELA
Code on Github for future reference
Using in FUNCTION:
CONCAT (string1, string2,…)
In your case, from what I understand, you want for a FUNCTION, so it would look like this:
BEGIN
DECLARE dado varchar(150);
DECLARE concDado varchar(150);
SET dado = 'teste';
SET concDado = CONCAT(dado , ' teste2');
Code on Github for future reference.
Hugs
Browser other questions tagged mysql
You are not signed in. Login or sign up in order to post.