Reputation: 5758
I have 3 fields in 1 table with data like this:
id | firstName | lastName
1 | Budi | Arsana
and I want to execute a query to create the following output:
id | fullName
1 | Budi Arsana
Notice that the output is combining the field firstName
and lastName
into fullName
Is this possible?
Upvotes: 1
Views: 30
Reputation: 2007
Use the CONCAT function! It is very simple to use it. Just Google it!
Upvotes: 0
Reputation: 270637
CONCAT()
them with a space in between:
SELECT id, CONCAT(firstName, ' ', lastName) AS fullName FROM table
Or use CONCAT_WS()
if you had more than two fields to join:
SELECT id, CONCAT_WS(' ', firstName, lastName, otherName) AS fullName FROM table
Upvotes: 4