2

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.

John Woo
  • 258,903
  • 69
  • 498
  • 492
Amarundo
  • 2,357
  • 15
  • 50
  • 68

2 Answers2

7

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

CONCAT('ABC', p1, p2, p3)
John Woo
  • 258,903
  • 69
  • 498
  • 492
1

Use GROUP_CONCAT() as explained further here.

Ross Rogers
  • 23,523
  • 27
  • 108
  • 164
CodeTalk
  • 3,571
  • 16
  • 57
  • 92