Pregunta

I'm in a Stored Procedure, and I need to concatenate 3 parameters PLUS a static string to create a unique ID for a table.

So the SP has, let's say, p1, p2 and p3 as varchar parameters, and I want to insert a new row in a table with values p1, p2, p3 and the 4th column would be 'ABC'+p1+p2+p3. I'm using || but it doesn't work. It returns 1. How do I concatenate in MySQL (xeround) and, also, do I need to use @p1 as in transact sql? I mean, using p1 worked for the INSERT.

Thanks.

¿Fue útil?

Solución

CONCAT is used for concatenation in mysql. So your code should be,

CONCAT('ABC', p1, p2, p3)

Otros consejos

Use GROUP_CONCAT() as explained further here.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top