Robert Rocha Robert Rocha - 4 days ago 4x
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)