Robert Rocha Robert Rocha - 5 months ago 31
MySQL Question

MySql store strings in variables and concatenate them to return them to the terminal

Let's say that I have:

SET @fname := "James", @mname := "Robert", @lname := "Maxon";

How would I set a variable that would contain the concatenated result of the above variables?

SET @concatenated = CONCAT(@fname, @mname, @mname)

or if you want to separate the names with a space:

SET @concatenated = CONCAT_WS(' ', @fname, @mname, @mname)