Concatenate 2 or more fields from a database table

If you want to get a result of firstname and lastname together as a single field, you will use CONCAT_WS(separator string, field1, field2,…) function.
Here’s I will show you how. For example, a table name Manager has 4 fields and some records as shown below.

id firstname lastname email_address
1 Linda Doe linda@mynetworksolutions.com
2 Didi Menita didi@yahoo.com
3 Jane Doe jane@adobe.com
4 Elisa Bethoni bethoni@microsft.com

You will use the following query statement to produce the expected result as shown below.

SELECT id, CONCAT_WS(‘ ‘,firstname,lastname) AS managername, email_address FROM Manager;

Results:

id managername email_address
1 Linda Doe linda@mynetworksolutions.com
2 Didi Menita didi@yahoo.com
3 Jane Doe jane@adobe.com
4 Elisa Bethoni bethoni@microsft.com