Robert Rocha Robert Rocha - 1 year ago 78
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?

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

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

SET @concatenated = CONCAT_WS(' ', @fname, @mname, @mname)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download